From: <Jef...@us...> - 2007-04-12 23:00:38
|
Revision: 14028 http://bzflag.svn.sourceforge.net/bzflag/?rev=14028&view=rev Author: JeffM2501 Date: 2007-04-12 16:00:38 -0700 (Thu, 12 Apr 2007) Log Message: ----------- move teleport message into it's own function add pack code for MSGteleport to the message file and support server side players. more whitespace. Modified Paths: -------------- trunk/bzflag/include/bzfsAPI.h trunk/bzflag/src/bzfs/bzfs.cxx trunk/bzflag/src/bzfs/bzfsAPI.cxx trunk/bzflag/src/bzfs/bzfsClientMessages.cxx trunk/bzflag/src/bzfs/bzfsClientMessages.h trunk/bzflag/src/bzfs/bzfsMessages.cxx trunk/bzflag/src/bzfs/bzfsMessages.h Modified: trunk/bzflag/include/bzfsAPI.h =================================================================== --- trunk/bzflag/include/bzfsAPI.h 2007-04-12 22:34:51 UTC (rev 14027) +++ trunk/bzflag/include/bzfsAPI.h 2007-04-12 23:00:38 UTC (rev 14028) @@ -1798,6 +1798,7 @@ virtual void setShotType ( int player, bz_eShotType shotType ); virtual void shotFired ( int player, unsigned short shotID, bz_eShotType shotType ); virtual void shotEnded( int player, unsigned short shotID, unsigned short reason ); + virtual void playerTeleported( int player, unsigned short from, unsigned short to ); int playerID; Modified: trunk/bzflag/src/bzfs/bzfs.cxx =================================================================== --- trunk/bzflag/src/bzfs/bzfs.cxx 2007-04-12 22:34:51 UTC (rev 14027) +++ trunk/bzflag/src/bzfs/bzfs.cxx 2007-04-12 23:00:38 UTC (rev 14028) @@ -2922,16 +2922,6 @@ } -static void sendTeleport(int playerIndex, uint16_t from, uint16_t to) -{ - void *buf, *bufStart = getDirectMessageBuffer(); - buf = nboPackUByte(bufStart, playerIndex); - buf = nboPackUShort(buf, from); - buf = nboPackUShort(buf, to); - broadcastMessage(MsgTeleport, (char*)buf-(char*)bufStart, bufStart, false); -} - - /** observers and paused players should not be sending updates.. punish the * ones that are paused since they are probably cheating. */ @@ -3137,17 +3127,9 @@ break; // player teleported - case MsgTeleport: { - uint16_t from, to; - - if (invalidPlayerAction(playerData->player, playerID, "teleport")) - break; - - buf = nboUnpackUShort(buf, from); - buf = nboUnpackUShort(buf, to); - sendTeleport(playerID, from, to); + case MsgTeleport: + handleTeleport(playerData,buf,len); break; - } // player sending a message case MsgMessage: Modified: trunk/bzflag/src/bzfs/bzfsAPI.cxx =================================================================== --- trunk/bzflag/src/bzfs/bzfsAPI.cxx 2007-04-12 22:34:51 UTC (rev 14027) +++ trunk/bzflag/src/bzfs/bzfsAPI.cxx 2007-04-12 23:00:38 UTC (rev 14028) @@ -3399,8 +3399,11 @@ void bz_ServerSidePlayerHandler::setShotType(int player, bz_eShotType shotType){} void bz_ServerSidePlayerHandler::shotFired(int player, unsigned short shotID, bz_eShotType shotType){} + void bz_ServerSidePlayerHandler::shotEnded(int player, unsigned short shotID, unsigned short reason){} +void bz_ServerSidePlayerHandler::playerTeleported( int player, unsigned short from, unsigned short to ){} + void bz_ServerSidePlayerHandler::setPlayerData(const char *callsign, const char *email, const char *token, const char *clientVersion, bz_eTeamType _team) { GameKeeper::Player *player=GameKeeper::Player::getPlayerByIndex(playerID); Modified: trunk/bzflag/src/bzfs/bzfsClientMessages.cxx =================================================================== --- trunk/bzflag/src/bzfs/bzfsClientMessages.cxx 2007-04-12 22:34:51 UTC (rev 14027) +++ trunk/bzflag/src/bzfs/bzfsClientMessages.cxx 2007-04-12 23:00:38 UTC (rev 14028) @@ -581,6 +581,19 @@ } } +void handleTeleport( GameKeeper::Player *playerData, void *buf, int len) +{ + uint16_t from, to; + + if (invalidPlayerAction(playerData->player, playerData->getIndex(), "teleport")) + return; + + buf = nboUnpackUShort(buf, from); + buf = nboUnpackUShort(buf, to); + + sendMsgTeleport(playerData->getIndex(), from, to); +} + const float *closestBase( TeamColor color, float *position ) { float bestdist = Infinity; Modified: trunk/bzflag/src/bzfs/bzfsClientMessages.h =================================================================== --- trunk/bzflag/src/bzfs/bzfsClientMessages.h 2007-04-12 22:34:51 UTC (rev 14027) +++ trunk/bzflag/src/bzfs/bzfsClientMessages.h 2007-04-12 23:00:38 UTC (rev 14028) @@ -36,6 +36,7 @@ void handleShotFired(void *buf, int len, NetHandler *handler); void handleShotEnded(GameKeeper::Player *playerData, void *buf, int len); void handleTankHit( GameKeeper::Player *playerData, void *buf, int len); +void handleTeleport( GameKeeper::Player *playerData, void *buf, int len); // util functions bool updatePlayerState(GameKeeper::Player *playerData, PlayerState &state, float timeStamp, bool shortState); Modified: trunk/bzflag/src/bzfs/bzfsMessages.cxx =================================================================== --- trunk/bzflag/src/bzfs/bzfsMessages.cxx 2007-04-12 22:34:51 UTC (rev 14027) +++ trunk/bzflag/src/bzfs/bzfsMessages.cxx 2007-04-12 23:00:38 UTC (rev 14028) @@ -583,19 +583,37 @@ void sendMsgShotEnd ( int player, unsigned short id, unsigned short reason ) { - void *buf, *bufStart = getDirectMessageBuffer(); - buf = nboPackUByte(bufStart, player); - buf = nboPackShort(buf, id); - buf = nboPackUShort(buf, reason); - relayMessage(MsgShotEnd, (char*)buf-(char*)bufStart, bufStart); + void *buf, *bufStart = getDirectMessageBuffer(); + buf = nboPackUByte(bufStart, player); + buf = nboPackShort(buf, id); + buf = nboPackUShort(buf, reason); + relayMessage(MsgShotEnd, (char*)buf-(char*)bufStart, bufStart); - // now do everyone who dosn't have network - for (int i = 0; i < curMaxPlayers; i++) - { - GameKeeper::Player* otherData = GameKeeper::Player::getPlayerByIndex(i); - if (otherData && otherData->playerHandler) - otherData->playerHandler->shotEnded(player,id,reason); - } + // now do everyone who dosn't have network + for (int i = 0; i < curMaxPlayers; i++) + { + GameKeeper::Player* otherData = GameKeeper::Player::getPlayerByIndex(i); + if (otherData && otherData->playerHandler) + otherData->playerHandler->shotEnded(player,id,reason); + } + } + +void sendMsgTeleport( int player, unsigned short from, unsigned short to ) +{ + void *buf, *bufStart = getDirectMessageBuffer(); + buf = nboPackUByte(bufStart, player); + buf = nboPackUShort(buf, from); + buf = nboPackUShort(buf, to); + + broadcastMessage(MsgTeleport, (char*)buf-(char*)bufStart, bufStart, false); + + // now do everyone who dosn't have network + for (int i = 0; i < curMaxPlayers; i++) + { + GameKeeper::Player* otherData = GameKeeper::Player::getPlayerByIndex(i); + if (otherData && otherData->playerHandler) + otherData->playerHandler->playerTeleported(player,from,to); + } } // network only messages Modified: trunk/bzflag/src/bzfs/bzfsMessages.h =================================================================== --- trunk/bzflag/src/bzfs/bzfsMessages.h 2007-04-12 22:34:51 UTC (rev 14027) +++ trunk/bzflag/src/bzfs/bzfsMessages.h 2007-04-12 23:00:38 UTC (rev 14028) @@ -48,6 +48,7 @@ void sendSetShotType ( int playerIndex, ShotType type ); void sendMsgShotBegin ( int player, unsigned short id, FiringInfo &firingInfo ); void sendMsgShotEnd ( int player, unsigned short id, unsigned short reason ); +void sendMsgTeleport ( int player, unsigned short from, unsigned short to ); // messages sent to just network users ( like client query ) int sendPlayerUpdateDirect(NetHandler *handler, GameKeeper::Player *otherData); This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |