From: <Jef...@us...> - 2008-04-23 05:35:03
|
Revision: 17076 http://bzflag.svn.sourceforge.net/bzflag/?rev=17076&view=rev Author: JeffM2501 Date: 2008-04-22 22:35:08 -0700 (Tue, 22 Apr 2008) Log Message: ----------- have physics drivers that kill just send a message to the server then have the server kill them if it wants to. Modified Paths: -------------- branches/v2_99_shot_branch/include/Protocol.h branches/v2_99_shot_branch/src/bzflag/ServerLink.cxx branches/v2_99_shot_branch/src/bzflag/ServerLink.h branches/v2_99_shot_branch/src/bzfs/bzfsClientMessages.cxx Modified: branches/v2_99_shot_branch/include/Protocol.h =================================================================== --- branches/v2_99_shot_branch/include/Protocol.h 2008-04-23 05:15:31 UTC (rev 17075) +++ branches/v2_99_shot_branch/include/Protocol.h 2008-04-23 05:35:08 UTC (rev 17076) @@ -72,6 +72,7 @@ const uint16_t MsgGameTime = 0x6774; // 'gt' const uint16_t MsgHandicap = 0x6863; // 'hc' const uint16_t MsgHit = 0x6869; // 'hi' +const uint16_t MsgHitDriver = 0x6864; // 'hd' const uint16_t MsgKilled = 0x6b6c; // 'kl' const uint16_t MsgLagState = 0x6c73; // 'ls' const uint16_t MsgLimboMessage = 0x6c6d; // 'lm' Modified: branches/v2_99_shot_branch/src/bzflag/ServerLink.cxx =================================================================== --- branches/v2_99_shot_branch/src/bzflag/ServerLink.cxx 2008-04-23 05:15:31 UTC (rev 17075) +++ branches/v2_99_shot_branch/src/bzflag/ServerLink.cxx 2008-04-23 05:35:08 UTC (rev 17076) @@ -1017,7 +1017,7 @@ void ServerLink::sendHit(const PlayerId &source, int id, bool shot) { - char msg[80]; + char msg[6]; unsigned char s = 0; if (shot) s = 1; @@ -1027,6 +1027,19 @@ buf = nboPackInt(buf, id); send(MsgHit, sizeof(msg), msg); } + +void ServerLink::sendHitDriver(const PlayerId &source, int id ) +{ + char msg[5]; + unsigned char s = 0; + if (shot) + s = 1; + void* buf = msg; + buf = nboPackUByte(buf, source); + buf = nboPackInt(buf, id); + send(MsgHitDriver, sizeof(msg), msg); +} + #endif void ServerLink::sendVarRequest() Modified: branches/v2_99_shot_branch/src/bzflag/ServerLink.h =================================================================== --- branches/v2_99_shot_branch/src/bzflag/ServerLink.h 2008-04-23 05:15:31 UTC (rev 17075) +++ branches/v2_99_shot_branch/src/bzflag/ServerLink.h 2008-04-23 05:35:08 UTC (rev 17076) @@ -82,8 +82,9 @@ #endif void sendEndShot(const PlayerId&, int shotId, int reason); - void sendHit(const PlayerId &source, int id, bool shot = true); - void sendVarRequest(); + void sendHit(const PlayerId &source, int id, bool shot = true); + void sendHitDriver(const PlayerId &source, int id ); + void sendVarRequest(); void sendAlive(const PlayerId playerId); void sendTeleport(int from, int to); Modified: branches/v2_99_shot_branch/src/bzfs/bzfsClientMessages.cxx =================================================================== --- branches/v2_99_shot_branch/src/bzfs/bzfsClientMessages.cxx 2008-04-23 05:15:31 UTC (rev 17075) +++ branches/v2_99_shot_branch/src/bzfs/bzfsClientMessages.cxx 2008-04-23 05:35:08 UTC (rev 17076) @@ -662,13 +662,32 @@ return true; } }; +class HitDriverHandler : public PlayerFirstHandler +{ +public: + virtual bool execute ( uint16_t &/*code*/, void * buf, int len ) + { + if (!player || len < 4) + return false; + int driverID = -1; + buf = nboUnpackInt(buf, driverID); + + PhysicsDriver *driver = PHYDRVMGR.getDriver(driverID); + if (!driver) + return true; + + if (driver->getIsDeath()) + playerKilled(player->getIndex(),PhysicsDriverDeath,driverID); + } +} + class HitHandler : public PlayerFirstHandler { public: virtual bool execute ( uint16_t &/*code*/, void * buf, int len ) { - if (!player || len < 3) + if (!player || len < 5) return false; if (player->player.isObserver() || !player->player.isAlive()) @@ -1017,6 +1036,7 @@ playerNetworkHandlers[MsgShotBegin] = new ShotBeginHandler; playerNetworkHandlers[MsgShotEnd] = new ShotEndHandler; playerNetworkHandlers[MsgHit] = new HitHandler; + playerNetworkHandlers[MsgHitDriver] = new HitDriverHandler; playerNetworkHandlers[MsgTeleport] = new TeleportHandler; playerNetworkHandlers[MsgMessage] = new MessageHandler; playerNetworkHandlers[MsgTransferFlag] = new TransferFlagHandler; This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |