|
From: <bul...@us...> - 2013-05-27 19:07:57
|
Revision: 22773
http://sourceforge.net/p/bzflag/code/22773
Author: bullet_catcher
Date: 2013-05-27 19:07:54 +0000 (Mon, 27 May 2013)
Log Message:
-----------
Remove const from message data that will be modified.
Use const_cast where it is, in fact, safe to modify const message data for rebroadcast.
Modified Paths:
--------------
trunk/bzflag/src/bzfs/bzfs.cxx
trunk/bzflag/src/bzfs/bzfs.h
Modified: trunk/bzflag/src/bzfs/bzfs.cxx
===================================================================
--- trunk/bzflag/src/bzfs/bzfs.cxx 2013-05-27 19:00:01 UTC (rev 22772)
+++ trunk/bzflag/src/bzfs/bzfs.cxx 2013-05-27 19:07:54 UTC (rev 22773)
@@ -258,7 +258,7 @@
// usually, the caller gets a buffer via getDirectMessageBuffer(), but for example
// for MsgShotBegin the receiving buffer gets used directly
static int directMessage(GameKeeper::Player &playerData,
- uint16_t code, int len, const void *msg)
+ uint16_t code, int len, void *msg)
{
if (playerData.isParting)
return -1;
@@ -271,7 +271,7 @@
return pwrite(playerData, bufStart, len + 4);
}
-void directMessage(int playerIndex, uint16_t code, int len, const void *msg)
+void directMessage(int playerIndex, uint16_t code, int len, void *msg)
{
GameKeeper::Player *playerData
= GameKeeper::Player::getPlayerByIndex(playerIndex);
@@ -281,7 +281,7 @@
directMessage(*playerData, code, len, msg);
}
-void broadcastMessage(uint16_t code, int len, const void *msg)
+void broadcastMessage(uint16_t code, int len, void *msg)
{
// send message to everyone
for (int i = 0; i < curMaxPlayers; i++) {
@@ -3542,7 +3542,7 @@
}
}
-static void shotUpdate(int playerIndex, const void *buf, int len)
+static void shotUpdate(int playerIndex, void *buf, int len)
{
GameKeeper::Player *playerData
= GameKeeper::Player::getPlayerByIndex(playerIndex);
@@ -3574,7 +3574,7 @@
broadcastMessage(MsgGMUpdate, len, buf);
}
-static void shotFired(int playerIndex, const void *buf, int len)
+static void shotFired(int playerIndex, void *buf, int len)
{
GameKeeper::Player *playerData
= GameKeeper::Player::getPlayerByIndex(playerIndex);
@@ -4383,7 +4383,7 @@
// Sanity check
if (len == FiringInfoPLen)
- shotFired(t, buf, int(len));
+ shotFired(t, const_cast<void *>(buf), int(len));
break;
// shot ended prematurely
@@ -4903,7 +4903,7 @@
}
case MsgGMUpdate:
- shotUpdate(t, buf, int(len));
+ shotUpdate(t, const_cast<void *>(buf), int(len));
break;
// FIXME handled inside uread, but not discarded
Modified: trunk/bzflag/src/bzfs/bzfs.h
===================================================================
--- trunk/bzflag/src/bzfs/bzfs.h 2013-05-27 19:00:01 UTC (rev 22772)
+++ trunk/bzflag/src/bzfs/bzfs.h 2013-05-27 19:07:54 UTC (rev 22773)
@@ -103,7 +103,7 @@
PlayerId dstPlayer,
const char *message);
extern char *getDirectMessageBuffer();
-extern void broadcastMessage(uint16_t code, int len, const void *msg);
+extern void broadcastMessage(uint16_t code, int len, void *msg);
extern void sendTeamUpdate(int playerIndex = -1,
int teamIndex1 = -1,
int teamIndex2 = -1);
@@ -112,7 +112,7 @@
extern void sendIPUpdate(int targetPlayer = -1, int playerIndex = -1);
extern void sendPlayerInfo(void);
extern void directMessage(int playerIndex, uint16_t code,
- int len, const void *msg);
+ int len, void *msg);
extern int getCurMaxPlayers();
extern bool areFoes(TeamColor team1, TeamColor team2);
extern PingPacket getTeamCounts();
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|