Update of /cvsroot/opentnl/tnl/zap
In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv18225/zap
Modified Files:
CTFGame.cpp CTFGame.h game.cpp game.h gameType.cpp gameType.h
projectile.cpp ship.cpp ship.h
Log Message:
Added scoring for player kills
Added scoring for CTF
Added flag drop messages
Index: ship.h
===================================================================
RCS file: /cvsroot/opentnl/tnl/zap/ship.h,v
retrieving revision 1.2
retrieving revision 1.3
diff -C2 -d -r1.2 -r1.3
*** ship.h 21 Apr 2004 23:47:34 -0000 1.2
--- ship.h 22 Apr 2004 00:35:49 -0000 1.3
***************
*** 63,66 ****
--- 63,67 ----
U32 lastFireTime;
F32 mHealth;
+ StringTableEntry mPlayerName;
Color color; // color of the ship
***************
*** 69,74 ****
bool hasExploded;
- StringTableEntry mPlayerName;
-
Move lastMove; // last client input move for this ship
--- 70,73 ----
***************
*** 79,83 ****
Ship(StringTableEntry playerName="", Point p = Point(0,0), Color c = Color(), F32 m = 1.0);
- void kill();
void emitMovementSparks();
void emitShipExplosion(Point pos);
--- 78,81 ----
***************
*** 91,94 ****
--- 89,93 ----
virtual void damageObject(DamageInfo *theInfo);
+ void kill(DamageInfo *theInfo);
void processMove(Move *theMove, U32 stateIndex);
Index: gameType.cpp
===================================================================
RCS file: /cvsroot/opentnl/tnl/zap/gameType.cpp,v
retrieving revision 1.5
retrieving revision 1.6
diff -C2 -d -r1.5 -r1.6
*** gameType.cpp 21 Apr 2004 22:40:43 -0000 1.5
--- gameType.cpp 22 Apr 2004 00:35:44 -0000 1.6
***************
*** 144,147 ****
--- 144,149 ----
cref.clientConnection = theClient;
+ cref.score = 0;
+
countTeamPlayers();
***************
*** 165,173 ****
}
! void GameType::controlObjectForClientKilled(GameConnection *theClient)
{
spawnShip(theClient);
}
void GameType::addClientGameMenuOptions(Vector<const char *> &menuOptions)
{
--- 167,180 ----
}
! void GameType::controlObjectForClientKilled(GameConnection *theClient, GameObject *clientObject, GameObject *killerObject)
{
spawnShip(theClient);
}
+ void GameType::controlObjectForClientRemoved(GameConnection *theClient, GameObject *clientObject)
+ {
+
+ }
+
void GameType::addClientGameMenuOptions(Vector<const char *> &menuOptions)
{
***************
*** 182,185 ****
--- 189,213 ----
}
+ TNL_IMPLEMENT_NETOBJECT_RPC(GameType, c2sChangeTeams, (),
+ NetClassGroupGameMask, RPCGuaranteedOrdered, RPCToGhostParent, 0)
+ {
+ if(mTeams.size() <= 1)
+ return;
+
+ GameConnection *source = (GameConnection *) NetObject::getRPCSourceConnection();
+ S32 clientIndex = findClientIndexByConnection(source);
+
+ // destroy the old ship
+ GameObject *co = source->getControlObject();
+ controlObjectForClientRemoved(source, co);
+ if(co)
+ getGame()->deleteObject(co, 0);
+
+ U32 newTeamId = (mClientList[clientIndex].teamId + 1) % mTeams.size();
+ mClientList[clientIndex].teamId = newTeamId;
+ s2cClientJoinedTeam(mClientList[clientIndex].clientId, newTeamId);
+ spawnShip(source);
+ }
+
TNL_IMPLEMENT_NETOBJECT_RPC(GameType, s2cAddClient, (U32 id, StringTableEntry name, bool isMyClient),
NetClassGroupGameMask, RPCGuaranteedOrdered, RPCToGhost, 0)
***************
*** 204,209 ****
GameObject *theControlObject = theClient->getControlObject();
if(theControlObject)
! delete theControlObject;
s2cRemoveClient(theClient->mClientId);
--- 232,238 ----
GameObject *theControlObject = theClient->getControlObject();
+ controlObjectForClientRemoved(theClient, theControlObject);
if(theControlObject)
! getGame()->deleteObject(theControlObject, 0);
s2cRemoveClient(theClient->mClientId);
***************
*** 242,265 ****
}
- TNL_IMPLEMENT_NETOBJECT_RPC(GameType, c2sChangeTeams, (),
- NetClassGroupGameMask, RPCGuaranteedOrdered, RPCToGhostParent, 0)
- {
- if(mTeams.size() <= 1)
- return;
-
- GameConnection *source = (GameConnection *) NetObject::getRPCSourceConnection();
- S32 clientIndex = findClientIndexByConnection(source);
-
- // destroy the old ship
- GameObject *co = source->getControlObject();
- if(co)
- getGame()->deleteObject(co, 0);
-
- U32 newTeamId = (mClientList[clientIndex].teamId + 1) % mTeams.size();
- mClientList[clientIndex].teamId = newTeamId;
- s2cClientJoinedTeam(mClientList[clientIndex].clientId, newTeamId);
- spawnShip(source);
- }
-
void GameType::onGhostAvailable(GhostConnection *theConnection)
{
--- 271,274 ----
Index: CTFGame.cpp
===================================================================
RCS file: /cvsroot/opentnl/tnl/zap/CTFGame.cpp,v
retrieving revision 1.4
retrieving revision 1.5
diff -C2 -d -r1.4 -r1.5
*** CTFGame.cpp 21 Apr 2004 22:40:40 -0000 1.4
--- CTFGame.cpp 22 Apr 2004 00:35:22 -0000 1.5
***************
*** 196,199 ****
--- 196,200 ----
s2cCTFMessage(CTFMsgReturnFlag, cl.clientId, theFlag->getTeamIndex());
theFlag->sendHome();
+ cl.score += 2;
}
else
***************
*** 212,215 ****
--- 213,217 ----
mountedFlag->dismount();
mountedFlag->sendHome();
+ cl.score += 5;
}
}
***************
*** 223,226 ****
--- 225,280 ----
}
+ U32 CTFGameType::checkFlagDrop(GameObject *theObject)
+ {
+ Ship *theShip = dynamic_cast<Ship *>(theObject);
+ if(!theShip)
+ return 0;
+
+ GameConnection *controlConnection = theShip->getControllingClient();
+ S32 clientIndex = findClientIndexByConnection(controlConnection);
+
+ if(clientIndex == -1)
+ return 0;
+
+ ClientRef &cl = mClientList[clientIndex];
+
+ U32 flagCount = 0;
+ // check if this client has an enemy flag mounted
+ for(S32 i = 0; i < theShip->mMountedItems.size();)
+ {
+ Item *theItem = theShip->mMountedItems[i];
+ CTFFlagItem *mountedFlag = dynamic_cast<CTFFlagItem *>(theItem);
+ if(mountedFlag)
+ {
+ s2cCTFMessage(CTFMsgDropFlag, cl.clientId, mountedFlag->getTeamIndex());
+ mountedFlag->dismount();
+ flagCount++;
+ }
+ else
+ i++;
+ }
+ return flagCount;
+ }
+
+ void CTFGameType::controlObjectForClientKilled(GameConnection *theClient, GameObject *clientObject, GameObject *killerObject)
+ {
+ GameConnection *killer = killerObject ? killerObject->getControllingClient() : NULL;
+ S32 killerIndex = findClientIndexByConnection(killer);
+ S32 clientIndex = findClientIndexByConnection(theClient);
+
+ if(killerIndex != -1)
+ {
+ mClientList[killerIndex].score++;
+ s2cKillMessage(mClientList[clientIndex].name, mClientList[killerIndex].name);
+ }
+ checkFlagDrop(clientObject);
+ spawnShip(theClient);
+ }
+
+ void CTFGameType::controlObjectForClientRemoved(GameConnection *theClient, GameObject *clientObject)
+ {
+ checkFlagDrop(clientObject);
+ }
+
static const char *CTFMessages[] =
{
***************
*** 228,231 ****
--- 282,286 ----
"%s captured the %s flag!",
"%s took the %s flag!",
+ "%s dropped the %s flag!",
};
***************
*** 235,238 ****
--- 290,294 ----
SFXFlagCapture,
SFXFlagSnatch,
+ SFXFlagDrop,
};
***************
*** 249,252 ****
--- 305,315 ----
}
+ TNL_IMPLEMENT_NETOBJECT_RPC(CTFGameType, s2cKillMessage, (StringTableEntry victim, StringTableEntry killer),
+ NetClassGroupGameMask, RPCGuaranteedOrdered, RPCToGhost, 0)
+ {
+ gGameUserInterface.displayMessage(Color(1.0f, 1.0f, 0.8f),
+ "%s zapped %s", killer.getString(), victim.getString());
+ }
+
TNL_IMPLEMENT_NETOBJECT(CTFFlagItem);
Index: projectile.cpp
===================================================================
RCS file: /cvsroot/opentnl/tnl/zap/projectile.cpp,v
retrieving revision 1.5
retrieving revision 1.6
diff -C2 -d -r1.5 -r1.6
*** projectile.cpp 20 Apr 2004 22:17:42 -0000 1.5
--- projectile.cpp 22 Apr 2004 00:35:44 -0000 1.6
***************
*** 101,105 ****
theInfo.damageAmount = 1;
theInfo.damageType = 0;
! theInfo.damagingObject = this;
theInfo.impulseVector = velocity;
--- 101,105 ----
theInfo.damageAmount = 1;
theInfo.damageType = 0;
! theInfo.damagingObject = mShooter;
theInfo.impulseVector = velocity;
Index: gameType.h
===================================================================
RCS file: /cvsroot/opentnl/tnl/zap/gameType.h,v
retrieving revision 1.2
retrieving revision 1.3
diff -C2 -d -r1.2 -r1.3
*** gameType.h 21 Apr 2004 22:40:43 -0000 1.2
--- gameType.h 22 Apr 2004 00:35:44 -0000 1.3
***************
*** 77,81 ****
virtual void serverRemoveClient(GameConnection *theClient);
! virtual void controlObjectForClientKilled(GameConnection *theClient);
virtual void spawnShip(GameConnection *theClient);
--- 77,83 ----
virtual void serverRemoveClient(GameConnection *theClient);
! virtual void controlObjectForClientKilled(GameConnection *theClient, GameObject *clientObject, GameObject *killerObject);
! virtual void controlObjectForClientRemoved(GameConnection *theClient, GameObject *clientObject);
!
virtual void spawnShip(GameConnection *theClient);
Index: game.cpp
===================================================================
RCS file: /cvsroot/opentnl/tnl/zap/game.cpp,v
retrieving revision 1.5
retrieving revision 1.6
diff -C2 -d -r1.5 -r1.6
*** game.cpp 21 Apr 2004 22:40:43 -0000 1.5
--- game.cpp 22 Apr 2004 00:35:43 -0000 1.6
***************
*** 197,206 ****
}
- void ServerGame::controlObjectForClientKilled(GameConnection *theConnection)
- {
- if(mGameType.isValid())
- mGameType->controlObjectForClientKilled(theConnection);
- }
-
void ServerGame::addClient(GameConnection *theConnection)
{
--- 197,200 ----
Index: game.h
===================================================================
RCS file: /cvsroot/opentnl/tnl/zap/game.h,v
retrieving revision 1.3
retrieving revision 1.4
diff -C2 -d -r1.3 -r1.4
*** game.h 20 Apr 2004 19:25:48 -0000 1.3
--- game.h 22 Apr 2004 00:35:44 -0000 1.4
***************
*** 154,158 ****
ServerGame(const Address &theBindAddress, U32 maxPlayers, const char *hostName);
- void controlObjectForClientKilled(GameConnection *theConnection);
void loadLevel(const char *fileName);
void processLevelLoadLine(int argc, const char **argv);
--- 154,157 ----
Index: CTFGame.h
===================================================================
RCS file: /cvsroot/opentnl/tnl/zap/CTFGame.h,v
retrieving revision 1.2
retrieving revision 1.3
diff -C2 -d -r1.2 -r1.3
*** CTFGame.h 21 Apr 2004 22:40:42 -0000 1.2
--- CTFGame.h 22 Apr 2004 00:35:43 -0000 1.3
***************
*** 43,46 ****
--- 43,49 ----
void renderInterfaceOverlay(bool scoreboardVisible);
void updateClientScoreboard(S32 clientIndex);
+ void controlObjectForClientKilled(GameConnection *theClient, GameObject *clientObject, GameObject *killerObject);
+ void controlObjectForClientRemoved(GameConnection *theClient, GameObject *clientObject);
+ U32 checkFlagDrop(GameObject *theObject);
enum {
***************
*** 55,61 ****
--- 58,66 ----
CTFMsgCaptureFlag,
CTFMsgTakeFlag,
+ CTFMsgDropFlag,
};
TNL_DECLARE_RPC(s2cCTFMessage, (U32 messageIndex, U32 clientId, U32 teamIndex));
+ TNL_DECLARE_RPC(s2cKillMessage, (StringTableEntry victim, StringTableEntry killer));
TNL_DECLARE_RPC(s2cScoreboardUpdate, (const Vector<RangedU32<0, MaxPing> > &pingTimes, const Vector<Int<9> > &scores));
TNL_DECLARE_CLASS(CTFGameType);
Index: ship.cpp
===================================================================
RCS file: /cvsroot/opentnl/tnl/zap/ship.cpp,v
retrieving revision 1.6
retrieving revision 1.7
diff -C2 -d -r1.6 -r1.7
*** ship.cpp 21 Apr 2004 20:19:07 -0000 1.6
--- ship.cpp 22 Apr 2004 00:35:45 -0000 1.7
***************
*** 35,38 ****
--- 35,39 ----
#include "UI.h"
#include "UIMenus.h"
+ #include "gameType.h"
#include <stdio.h>
***************
*** 154,158 ****
{
mHealth = 0;
! kill();
}
}
--- 155,159 ----
{
mHealth = 0;
! kill(theInfo);
}
}
***************
*** 444,448 ****
}
! void Ship::kill()
{
if(isGhost())
--- 445,449 ----
}
! void Ship::kill(DamageInfo *theInfo)
{
if(isGhost())
***************
*** 457,461 ****
if(controllingClient)
{
! gServerGame->controlObjectForClientKilled(controllingClient);
}
}
--- 458,464 ----
if(controllingClient)
{
! GameType *gt = getGame()->getGameType();
! if(gt)
! gt->controlObjectForClientKilled(controllingClient, this, theInfo->damagingObject);
}
}
***************
*** 578,583 ****
// Make it a nice pastel
! glColor3f(color.r*1.2,color.g*1.2,color.b*1.2);
UserInterface::drawString( UserInterface::getStringWidth(14, buff) * -0.5, 30, 14, buff );
}
--- 581,591 ----
// Make it a nice pastel
! glEnable(GL_BLEND);
! glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);
! glColor4f(1,1,1,0.55);
! //glColor3f(color.r*1.2,color.g*1.2,color.b*1.2);
UserInterface::drawString( UserInterface::getStringWidth(14, buff) * -0.5, 30, 14, buff );
+ glDisable(GL_BLEND);
+ glBlendFunc(GL_ONE, GL_ZERO);
}
|