Commit Graph

79 Commits

Author SHA1 Message Date
d32facf363 swithed to blackbox testing
just because i am lazy
2023-11-25 23:11:19 -06:00
4419260cd0 rename TestPacket -> TestPacketEncodeDecode
also, verify encoded bytes to a sample
2023-11-22 20:04:53 -06:00
9df5a3d0d5 start packet_test.go; minor packet.go refactoring 2023-11-22 18:18:22 -06:00
7d83732e44 genstructs.py: refactor; use match/case statement
- lol, i had no idea python *FINALLY* added a switch/case equivalent.
sadly though, it looks like the generated python bytecode is
nearly identical in performance.
there's no lookup table magic for match/case, and is almost
identical to if/else if/else. it amounts to syntax sugar 😭
2023-11-22 16:02:00 -06:00
7eece044c5 more better db tests; use psql 15, not latest
- our db_test tests now use psql version 15 (which is the same
version our docker-compose file uses) for consistency.
- also added another test, TestDBPlayer
2023-11-22 15:41:31 -06:00
e8f8129b35 fix: SetPlayerInventorySlots actually uses tx now
lol, must've been a typo
2023-11-21 14:13:55 -06:00
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
459b71a109 fix: Chunks are now goroutine safe
- added Chunk.ForEachEntity()
- refactored SendPacketExclude() to use it
- Chunk.Entities is now Chunk.entities, which is private.
- Chunk.AddEntity() && RemoveEntity() now lock the chunk mutex
2023-11-21 01:49:57 -06:00
06f4a4d33f minor chunk refactoring
- rename GetChunk -> GetChunkPos
- rename SetChunk -> SetChunkPos
2023-11-21 01:36:23 -06:00
3e04103ae4 fix formatting 2023-09-18 21:09:20 -05:00
3559682d18 genstructs.py: generate PacketIDToString()
this will be nice to have for debugging
2023-09-18 20:46:37 -05:00
a78dedcb89 better readme 2023-08-23 18:38:14 -05:00
dcb86e2518 more minor refactoring 2023-08-23 18:37:57 -05:00
458e907c99 moved 'core' to 'internal' 2023-08-23 18:16:24 -05:00
74b68863b1 updated readme 2023-08-23 18:05:03 -05:00
83b664da93 minor refactoring, fixed go-staticcheck warnings 2023-08-23 18:03:14 -05:00
670d4a514c more better CNPeer.Send()
this fixes a race condition where if 2 goroutines try to send a packet at the same time, they could end up being
malformed due to the 2 separate calls to peer.conn.Write().

instead of writing the packet size to peer.conn.Write() directly, we make space in buf for the packet size,
and patch it in place. this lets us get away with only having 1 call to peer.conn.Write() which will ensure that
the full packet is written properly and be goroutine safe :3
2023-08-23 17:38:10 -05:00
7ebe80d6e3 fixed FinishPlayer assigning items to the wrong slots 2023-07-02 17:24:15 -05:00
f27e72d68d send chat packets to *all* players 2023-06-27 22:05:08 -05:00
215e313c43 added chat :D 2023-06-27 21:49:11 -05:00
3559d9ba9b switched NPC autoincremented ID to atomic int 2023-06-27 20:06:51 -05:00
c4325475ed minor renaming 2023-06-27 00:48:17 -05:00
fd41b32b70 added NPCs; added tdata submodule
- use environment variable TDATA_PATH to specify the location of the
  tdata directory
2023-06-27 00:36:02 -05:00
80dc876517 added shard.addEntity() and shard.removeEntity() 2023-06-27 00:11:00 -05:00
c09a6cfd25 fixed sent server time 2023-06-25 18:29:31 -05:00
8f00a0c492 movement.go: added support for basic movement packets
you should be able to view other players and jump around together,
although while testing locally one of the clients would always trigger
the "Some irregularities have been found with your connection to the
server, so your game will be closed" speed check for some reason ???

really not sure, might just be my machine

chunking uhhh works ? kind of, not tested for more than a few seconds
before one of the clients disconnects
2023-06-25 04:27:42 -05:00
f6ab7a9b5d started chunking 2023-06-25 03:33:17 -05:00
f0b9bc6ed6 god forgive me for this commit 2023-06-25 01:51:21 -05:00
dfc00bcb52 shardServer: simplified peer map logic 2023-06-24 22:36:04 -05:00
1da82ac750 include AccountID in loginMetadata 2023-06-22 18:12:31 -05:00
d42a34535b split redis.go 2023-06-22 18:05:02 -05:00
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
983588b6c9 dockerfile: switch to scratch
- build.sh: disables CGO and specifies linux
- we really don't need the cstdlib now, and we don't need a busybox shell
2023-06-20 18:33:29 -05:00
124bb77f8d dockerfile: specified entrypoint 2023-06-20 18:24:17 -05:00
e4cf64d7bc started docker image 2023-06-20 02:12:15 -05:00
727c68aef3 server: split login/ and shard/ 2023-03-27 17:02:13 -05:00
70e42b5d79 server/shard: added UpdatePlayer(), which should be used whenever player struct state needs to be updated to prevent race conditions 2023-03-26 21:08:13 -05:00
bb29a988b3 landwalker achieved!
- the shard's ip sent to the client via the login server is currently hardcoded in config/config.go
- no packets other than P_CL2FE_REQ_PC_ENTER and P_CL2FE_REQ_PC_LOADING_COMPLETE are supported via the shard server
2023-03-22 17:07:16 -05:00
5b2a8b838e major refactoring: db.Player is now core.Player
- misc. cleanup
- core/db/players.go: works with core.Player types, will also grab inventory table
2023-03-22 00:30:58 -05:00
735bdc5b36 protocol: added CNPeer
- moved Peer from the server package to the protocol package, it was also renamed to CNPeer as most fusionfall specific constants in the client use the 'CN' prefix.
2023-03-18 16:40:20 -05:00
1357de99aa server: started ShardServer
- protocol: added GenSerialKey() which securely generates an EnterSerialKey
- login server accepts a shard via LoginServer.AddShard()
- login server will pass LoginMetaData to the selected shard via ShardServer.QueueLogin()
- misc. refactoring
2023-03-17 16:27:47 -05:00
7a26ffdcf7 server/peer: wrap 'defer pool.Put()' in a closure 2023-03-11 15:02:01 -06:00
cbe308a0bd misc. db.GetPlayers() result is now truncated 2023-03-11 03:28:11 -06:00
c62ed5d101 db: GetPlayerInventorySlots() can just build the array the first pass, no? 2023-03-11 02:06:39 -06:00
a0a108a605 more better 2023-03-11 01:48:26 -06:00
850dd59967 protocol/packet: accept structs by value for encoding
- server/loginServer: no longer sending packets by pointer, except in cases like AcceptLogin(), which operates on a sent structure slice. since these are already allocated, no need to copy them
2023-03-11 00:24:20 -06:00
00fa94162c server: refactoring; start support for variadic packets 2023-03-10 23:59:13 -06:00
d60638d555 loginServer/peer: peer no longer uses panic/recover for error recovery 2023-03-10 20:30:16 -06:00
857250bf33 protocol/packet: don't panic, return errors 2023-03-10 20:07:48 -06:00
f1552830a0 protocol/packet: switch away from allocation
- Packet struct is small enough that allocation for it is really unnecessary, and can be passed around by value fairly easily
2023-03-10 20:00:06 -06:00