codlocker / werewolves-go

Werewolves Game implementation in Golang
GNU General Public License v3.0
0 stars 0 forks source link

If a player joins a already running game, it gets the message - the game is already running. if the player types quit, he is able to craash the moderator process as well #24

Closed jthak002 closed 6 months ago

jthak002 commented 6 months ago

the log output of the player is here:

$ bin/server
127.0.0.1:4000
2024/04/20 11:46:47 INFO Server running at PID : 127.0.0.1:4000/server/primary
2024/04/20 11:46:54 INFO new client connected id=client/jeetthakkar addr=127.0.0.1:55649 sender=127.0.0.1:55649/client/jeetthakkar username=jeetthakkar
End time for state connect = 2024-04-20 11:47:47.827159 -0700 MST m=+60.004553501
End time for state connect = 2024-04-20 11:47:47.827159 -0700 MST m=+60.004553501
2024/04/20 11:47:14 INFO new client connected id=client/delta-9 addr=127.0.0.1:38287 sender=127.0.0.1:38287/client/delta-9 username=delta-9
End time for state connect = 2024-04-20 11:47:47.827159 -0700 MST m=+60.004553501
2024/04/20 11:47:33 INFO new client connected id=client/player10 addr=127.0.0.1:24611 sender=127.0.0.1:24611/client/player10 username=player10
127.0.0.1:55649  will be a werewolf.
127.0.0.1:38287  will be a werewolf.
127.0.0.1:24611  will be a werewolf.
Print Users
127.0.0.1:55649 has been assigned jeetthakkar username, has role werewolf with alive status true
127.0.0.1:38287 has been assigned delta-9 username, has role townsperson with alive status true
127.0.0.1:24611 has been assigned player10 username, has role townsperson with alive status true
2024/04/20 11:48:51 INFO Moderator has chosen to die.
2024/04/20 11:48:51 ERROR Actor crashed and restarted pid=server/primary stack="goroutine 44 [running]\nmain.(*server).Receive\n\t/Users/jeetthakkar/GolandProjects/werewolves-go/server/main.go:96\ngithub.com/anthdm/hollywood/actor.(*process).invokeMsg\n\t/Users/jeetthakkar/go/pkg/mod/github.com/anthdm/hollywood@v0.0.0-20240115210651-dd34702ee21f/actor/process.go:115\ngithub.com/anthdm/hollywood/actor.(*process).Invoke\n\t/Users/jeetthakkar/go/pkg/mod/github.com/anthdm/hollywood@v0.0.0-20240115210651-dd34702ee21f/actor/process.go:99\ngithub.com/anthdm/hollywood/actor.(*Inbox).run\n\t/Users/jeetthakkar/go/pkg/mod/github.com/anthdm/hollywood@v0.0.0-20240115210651-dd34702ee21f/actor/inbox.go:86\ngithub.com/anthdm/hollywood/actor.(*Inbox).process\n\t/Users/jeetthakkar/go/pkg/mod/github.com/anthdm/hollywood@v0.0.0-20240115210651-dd34702ee21f/actor/inbox.go:72\n" reason="runtime error: invalid memory address or nil pointer dereference" restarts=1
codlocker commented 6 months ago

@jthak002 I dont think the game was running here as the log states the interrupt has been sent by server to the clients.

The log INFO Moderator has chosen to die.

occurs when the server is interrupted by a SIGINT.

jthak002 commented 6 months ago

image

bottom right window shows a client who joined after the game started and as soon as quit was entered on the client, it terminated the server without pressing ctrl + c.

e.SendWithSender(serverPID, &types.Disconnect{}, clientPID)

line 99 of the client/main.go sends the the disconnect message - maybe in the server we check if the game is running, and if it is we do not accept the client's disconnect message. possible fix will include commenting out the line, if an exit is premature or configuring the server to intelligently process disconnect messages.