Commit Graph

38 Commits

Author SHA1 Message Date
CPunch cafca9093c login_test: use TestCharCreate from testutil 2024-03-03 13:14:37 -06:00
CPunch 02afe67ac3 fix: os.Exit() kills any deferred cleanup functions
os.Exit() itself is now also a deferred function, which will be the last to run.
2024-02-05 11:59:50 -06:00
CPunch 79f68187bf testutil: DummyPeer now holds onto the *is.Is
makes SendAndRecv a bit cleaner imo
2024-02-04 11:26:48 -06:00
CPunch 0a28dbcc3e removed util
- WaitWithTimeout && SelectWithTimeout have been moved to internal/testutil
- GetTime has been moved to cnet/protocol
2024-02-01 18:25:49 -06:00
CPunch 1a6de671e5 moved 'testutil' to 'internal/testutil' 2024-02-01 17:28:00 -06:00
CPunch 556878544d testutil: refactoring && cleanup
added a simple DummyPeer struct to simplify creation, send/recv and cleanup
2024-02-01 17:21:56 -06:00
CPunch bfcbe6d3d6 started testutil: login_test now uses these helpers
should simplify new tests in the future
2024-02-01 17:11:50 -06:00
CPunch 23170093ee login_test: fix minor memory leak
defer PutBuffer so that the event packet is returned to the pool
2023-12-07 21:37:16 -06:00
CPunch 2bd61dc571 login_test: more stale comments lol 2023-12-06 20:23:29 -06:00
CPunch cba01a877d login_test: fix sendAndRecv
removed the stale typecast lol
2023-12-06 20:17:36 -06:00
CPunch e1b9fa5d99 login_test: refactor, abstracted send and recv
validation
2023-12-06 20:15:06 -06:00
CPunch 77751a2aa0 login_tests: annotate tests 2023-12-06 17:35:02 -06:00
CPunch 01ebf4499f login_test: added TestCharacterSequence
tests the complete account/character creation sequence of packets
2023-12-06 17:08:59 -06:00
CPunch 3a14d807d2 login: minor refactoring 2023-12-06 17:08:05 -06:00
CPunch 2a6fb25f03 use passed context.Context 2023-12-04 20:45:23 -06:00
CPunch 0ebd162af0 login_test: minor cleanup 2023-12-04 20:40:48 -06:00
CPunch d1763418a8 removed useless closure 2023-12-04 20:33:53 -06:00
CPunch afd5c9ef23 added login_test 2023-12-04 20:28:17 -06:00
CPunch ac62f7d64e moved config/ -> internal/config 2023-12-02 22:09:11 -06:00
CPunch 557117f093 moved internal/protocol -> cnet/protocol 2023-12-01 19:56:23 -06:00
CPunch b07e9ddbcb merged internal/service -> cnet/service 2023-12-01 19:22:49 -06:00
CPunch af867ccff2 renamed cnet.CNPeer -> cnet.Peer 2023-12-01 19:15:00 -06:00
CPunch c60017f78f rename cnpeer package to cnet 2023-12-01 17:11:41 -06:00
CPunch e355af19ab moved internal/protocol/cnpeer to cnpeer
also started a util package
2023-12-01 15:29:19 -06:00
CPunch f4b17906ce more protocol/service refactor
- removed protocol.Event: CNPeers now send protocol.PacketEvents
- peer uData is held in CNPeer, use SetUserData() and UserData() to
set/read it
- Service.PacketHandler calback has changed, removed uData:
switched calls to peer.SetUserData() and peer.UserData() where appropriate
- service.Service lots of tidying up, removed dependence on old
protocol.Event.
- service.Service && protocol.CNPeer now accept a cancelable context.
hooray graceful shutdowns and unit tests!
- general cleanup
2023-12-01 00:56:34 -06:00
CPunch c0ba365cf5 CNPeer/Service refactor
- each CNPeer is given a unique chan *protocol.Event to pass events to
the service.handleEvents() loop. this is now passed to CNPeer.Handler()
as opposed to NewCNPeer().
- service has basically been rewritten. handleEvents() main loop uses
reflect.SelectCase() now to handle all of the eRecv channels for each
peer
- new protocol Event type: EVENT_CLIENT_CONNECT
- Added service_test.go; blackbox-styled testing like the others.
TestService() starts a service and spins up  a bunch of dummy peers
and verifies that each packet sent causes the corresponding packet
handler to be called.
2023-11-29 19:57:45 -06:00
CPunch d0346b2382 use proper errors for db.Err
- switch to using errors.Is where applicable
2023-11-29 19:52:10 -06:00
CPunch 1f66acfd25 holy refactor
started out as me making a service abstraction..

- db.Player exists again, and entity.Player uses it as an embedded struct
- chunk.ForEachEntity() lets you add/remove entities during iteration now
- removed account related fields from CNPeer
- protocol/pool has been merged with protocol.
use protocol.GetBuffer() and protocol.PutBuffer().
- new protocol/internal/service!
service.Service is an abstraction layer to handle multiple CNPeer*
connections and allows you to associate each with an interface{} uData.
In the future it might also handle a task queue for jobs that
modify/interact with the player's uData, called from service.handleEvents()
- PacketHandler callback type has a new param! uData is passed as well now
- much of loginserver/shardserver is now handled by the shared service
abstraction
- SHARD: NPC_ENTER packets are now sent on player loading complete
rather than on enter.
2023-11-27 21:23:28 -06:00
CPunch f95cc2cae7 test: started internal/db test cases
- we use github.com/bitcomplete/sqltestutil to spin up a postgresql
container to test against
- minor error variable refactoring
2023-11-21 13:58:59 -06:00
CPunch dcb86e2518 more minor refactoring 2023-08-23 18:37:57 -05:00
CPunch 458e907c99 moved 'core' to 'internal' 2023-08-23 18:16:24 -05:00
unknown 3559d9ba9b switched NPC autoincremented ID to atomic int 2023-06-27 20:06:51 -05:00
unknown c4325475ed minor renaming 2023-06-27 00:48:17 -05:00
CPunch c09a6cfd25 fixed sent server time 2023-06-25 18:29:31 -05:00
unknown f0b9bc6ed6 god forgive me for this commit 2023-06-25 01:51:21 -05:00
unknown 1da82ac750 include AccountID in loginMetadata 2023-06-22 18:12:31 -05:00
unknown d7445e0f0f Switched to redis/postgres, major refactoring
- loginMetadata is passed to shards through redis now
- shards announce they're alive via redis.AnnounceShard() which just
  populates a hashset keyed 'shards'
- login servers grab the 'shards' hashset and randomly picks a shard to
  pass the player to (for now)
- ./service shard && ./service login
- Many new environment variables, check config/config.go for more info.
  or for a tl;dr just read the Dockerfile for the required ones
- Shard and login services now run in different processes ! (and
  containers?? wooaaah)
2023-06-22 01:53:38 -05:00
CPunch 727c68aef3 server: split login/ and shard/ 2023-03-27 17:02:13 -05:00