Move Game.Messages to ::Messages

stable-5.2
Günther Brammer 2009-06-05 20:12:43 +02:00
parent 6e4df10454
commit 31e27e91f5
14 changed files with 50 additions and 54 deletions

View File

@ -26,11 +26,9 @@
#ifdef C4ENGINE
#include <C4Client.h>
#include <C4GameParameters.h>
#include <C4PlayerInfo.h>
#include <C4RoundResults.h>
#include <C4GameMessage.h>
#include <C4Weather.h>
#include <C4GameObjects.h>
#include <C4Scenario.h>
@ -77,7 +75,6 @@ class C4Game
C4PlayerInfoList &PlayerInfos; // Shortcut
C4PlayerInfoList &RestorePlayerInfos; // Shortcut
C4RoundResults RoundResults;
C4GameMessageList Messages;
C4Weather Weather;
C4MaterialMap Material;
C4GameObjects Objects;

View File

@ -101,11 +101,30 @@ class C4GameMessageList
bool Append(int32_t iType, const char *szText, C4Object *pTarget, int32_t iPlayer, int32_t iX, int32_t iY, uint8_t bCol, bool fNoDuplicates = false);
};
void GameMsgObject(const char *szText, C4Object *pTarget, int32_t iFCol=FWhite);
void GameMsgObjectPlayer(const char *szText, C4Object *pTarget, int32_t iPlayer, int32_t iFCol=FWhite);
void GameMsgGlobal(const char *szText, int32_t iFCol=FWhite);
void GameMsgPlayer(const char *szText, int32_t iPlayer, int32_t iFCol=FWhite);
extern C4GameMessageList Messages;
void GameMsgObjectDw(const char *szText, C4Object *pTarget, uint32_t dwClr);
inline void GameMsgObject(const char *szText, C4Object *pTarget, int32_t iFCol=FWhite)
{
::Messages.New(C4GM_Target,szText,pTarget,NO_OWNER,0,0,(uint8_t) iFCol);
}
inline void GameMsgObjectPlayer(const char *szText, C4Object *pTarget, int32_t iPlayer, int32_t iFCol=FWhite)
{
::Messages.New(C4GM_TargetPlayer,szText,pTarget,iPlayer,0,0,(uint8_t) iFCol);
}
inline void GameMsgGlobal(const char *szText, int32_t iFCol=FWhite)
{
::Messages.New(C4GM_Global,szText,NULL,ANY_OWNER,0,0,(uint8_t) iFCol);
}
inline void GameMsgPlayer(const char *szText, int32_t iPlayer, int32_t iFCol=FWhite)
{
::Messages.New(C4GM_GlobalPlayer,szText,NULL,iPlayer,0,0,(uint8_t) iFCol);
}
inline void GameMsgObjectDw(const char *szText, C4Object *pTarget, uint32_t dwClr)
{
::Messages.New(C4GM_Target,szText,pTarget,NO_OWNER,0,0,dwClr);
}
#endif

View File

@ -25,7 +25,7 @@
#ifndef BIG_C4INCLUDE
#include <C4Object.h>
#include <C4Config.h>
#include <C4Game.h>
#include <C4GameMessage.h>
#include <C4Wrappers.h>
#endif
@ -43,9 +43,9 @@ void C4AulExecError::show()
// debug mode object message
if (Game.DebugMode)
if (cObj)
Game.Messages.New(C4GM_Target,sMessage,cObj,NO_OWNER);
::Messages.New(C4GM_Target,sMessage,cObj,NO_OWNER);
else
Game.Messages.New(C4GM_Global,sMessage,NULL,ANY_OWNER);
::Messages.New(C4GM_Global,sMessage,NULL,ANY_OWNER);
#endif
}

View File

@ -31,7 +31,7 @@
#include <C4ObjectCom.h>
#include <C4ObjectInfo.h>
#include <C4Random.h>
#include <C4Game.h>
#include <C4GameMessage.h>
#include <C4ObjectMenu.h>
#include <C4Player.h>
#include <C4Wrappers.h>
@ -2109,7 +2109,7 @@ void C4Command::Fail(const char *szFailMessage)
// Message (if not empty)
if (!!str)
{
Game.Messages.Append(C4GM_Target, str.getData(), l_Obj, NO_OWNER, 0, 0, FWhite, TRUE);
::Messages.Append(C4GM_Target, str.getData(), l_Obj, NO_OWNER, 0, 0, FWhite, TRUE);
}
// Fail sound
StartSoundEffect("CommandFailure*",false,100,l_Obj);

View File

@ -39,6 +39,7 @@
#include <C4RankSystem.h>
#include <C4PXS.h>
#include <C4MassMover.h>
#include <C4GameMessage.h>
#endif
// *** C4ControlPacket

View File

@ -63,6 +63,7 @@
#include <C4MessageInput.h>
#include <C4MassMover.h>
#include <C4RankSystem.h>
#include <C4GameMessage.h>
#endif
#include <StdFile.h>
@ -560,7 +561,7 @@ void C4Game::Clear()
Material.Clear();
TextureMap.Clear(); // texture map *MUST* be cleared after the materials, because of the patterns!
GraphicsResource.Clear();
Messages.Clear();
::Messages.Clear();
MessageInput.Clear();
Info.Clear();
Title.Clear();
@ -772,7 +773,7 @@ BOOL C4Game::Execute() // Returns true if the game is over
EXEC_S_DR( Players.Execute(); , PlayersStat , "PlrEx")
//FIXME: C4Application::Execute should do this, but what about the stats?
EXEC_S_DR( Application.MusicSystem.Execute(); , MusicSystemStat , "Music")
EXEC_S_DR( Messages.Execute(); , MessagesStat , "MsgEx")
EXEC_S_DR( ::Messages.Execute(); , MessagesStat , "MsgEx")
EXEC_S_DR( Script.Execute(); , ScriptStat , "Scrpt")
EXEC_DR( MouseControl.Execute(); , "Input")
@ -942,7 +943,7 @@ void C4Game::ClearPointers(C4Object *pObj)
{
BackObjects.ClearPointers(pObj);
ForeObjects.ClearPointers(pObj);
Messages.ClearPointers(pObj);
::Messages.ClearPointers(pObj);
ClearObjectPtrs(pObj);
Players.ClearPointers(pObj);
GraphicsSystem.ClearPointers(pObj);
@ -1694,7 +1695,7 @@ void C4Game::Default()
PXS.Default();
GraphicsSystem.Default();
C4S.Default();
Messages.Default();
::Messages.Default();
MessageInput.Default();
Info.Default();
Title.Default();
@ -2194,7 +2195,7 @@ BOOL C4Game::ReloadDef(C4ID id)
fSucc = false;
}
// update game messages
Messages.UpdateDef(id);
::Messages.UpdateDef(id);
// done
return fSucc;
}

View File

@ -346,13 +346,13 @@ bool C4GameMessageList::Append(int32_t iType, const char *szText, C4Object *pTar
C4GameMessage *cmsg = NULL;
if (iType == C4GM_Target)
{
for (cmsg=Game.Messages.First; cmsg; cmsg=cmsg->Next)
for (cmsg=::Messages.First; cmsg; cmsg=cmsg->Next)
if (pTarget == cmsg->Target)
break;
}
if (iType == C4GM_Global || iType == C4GM_GlobalPlayer)
{
for (cmsg=Game.Messages.First; cmsg; cmsg=cmsg->Next)
for (cmsg=::Messages.First; cmsg; cmsg=cmsg->Next)
if (iPlayer == cmsg->Player)
break;
}
@ -393,3 +393,4 @@ void C4GameMessageList::Draw(C4TargetFacet &cgo, int32_t iPlayer, float Zoom)
cmsg->Draw(cgo,iPlayer,Zoom);
}
C4GameMessageList Messages;

View File

@ -38,7 +38,7 @@
#include <C4Record.h>
#endif
#include <C4Material.h>
#include <C4Game.h>
#include <C4GameMessage.h>
#include <C4Application.h>
#include <C4Wrappers.h>
#include <C4Stat.h>

View File

@ -47,6 +47,7 @@
#include <C4ObjectMenu.h>
#include <C4RankSystem.h>
#include <C4GameVersion.h>
#include <C4GameMessage.h>
#endif
void DrawVertex(C4Facet &cgo, int32_t tx, int32_t ty, int32_t col, int32_t contact)
@ -1714,7 +1715,7 @@ BOOL C4Object::Build(int32_t iLevel, C4Object *pBuilder)
// ...tell builder to acquire the material
pBuilder->AddCommand(C4CMD_Acquire,NULL,0,0,50,NULL,TRUE,NeededMaterial,FALSE,1);
// ...game message if not overloaded
Game.Messages.New(C4GM_Target,GetNeededMatStr(pBuilder),pBuilder,pBuilder->Controller);
::Messages.New(C4GM_Target,GetNeededMatStr(pBuilder),pBuilder,pBuilder->Controller);
}
// Still in need: done/fail
return FALSE;

View File

@ -32,7 +32,7 @@
#include <C4Physics.h>
#include <C4Command.h>
#include <C4Random.h>
#include <C4Game.h>
#include <C4GameMessage.h>
#include <C4Wrappers.h>
#include <C4ObjectMenu.h>
#include <C4Player.h>

View File

@ -42,6 +42,7 @@
#include <C4GameOverDlg.h>
#include <C4ObjectMenu.h>
#include <C4MouseControl.h>
#include <C4GameMessage.h>
#endif
#define C4FOW_Def_View_RangeX 500

View File

@ -44,6 +44,7 @@
#include <C4RankSystem.h>
#include <C4PXS.h>
#include <C4MessageInput.h>
#include <C4GameMessage.h>
#endif
//========================== Some Support Functions =======================================
@ -2526,8 +2527,8 @@ static C4Value FnAddMessage_C4V(C4AulContext *cthr, C4Value *c4vMessage, C4Value
if (!szMessage) return C4VBool(false);
C4Object * pObj = c4vObj->getObj();
if (pObj) Game.Messages.Append(C4GM_Target,FnStringFormat(cthr,FnStringPar(szMessage),iPar0,iPar1,iPar2,iPar3,iPar4,iPar5,iPar6,iPar7).getData(),pObj,NO_OWNER,0,0,FWhite);
else Game.Messages.Append(C4GM_Global,FnStringFormat(cthr,FnStringPar(szMessage),iPar0,iPar1,iPar2,iPar3,iPar4,iPar5,iPar6,iPar7).getData(),0,ANY_OWNER,0,0,FWhite);
if (pObj) ::Messages.Append(C4GM_Target,FnStringFormat(cthr,FnStringPar(szMessage),iPar0,iPar1,iPar2,iPar3,iPar4,iPar5,iPar6,iPar7).getData(),pObj,NO_OWNER,0,0,FWhite);
else ::Messages.Append(C4GM_Global,FnStringFormat(cthr,FnStringPar(szMessage),iPar0,iPar1,iPar2,iPar3,iPar4,iPar5,iPar6,iPar7).getData(),0,ANY_OWNER,0,0,FWhite);
return C4VBool(true);
}
@ -6282,7 +6283,7 @@ static bool FnCustomMessage(C4AulContext *ctx, C4String *pMsg, C4Object *pObj, l
sMsg.Ref(szMsg);
if (dwFlags & C4GM_DropSpeech) sMsg.SplitAtChar('$', NULL);
// create it!
return Game.Messages.New(iType,sMsg,pObj,iOwner,iOffX,iOffY,(uint32_t)dwClr, idDeco, sPortrait ? sPortrait->GetCStr() : NULL, dwFlags, iHSize);
return ::Messages.New(iType,sMsg,pObj,iOwner,iOffX,iOffY,(uint32_t)dwClr, idDeco, sPortrait ? sPortrait->GetCStr() : NULL, dwFlags, iHSize);
}
/*static long FnSetSaturation(C4AulContext *ctx, long s)

View File

@ -43,6 +43,7 @@
#include <C4ObjectMenu.h>
#include <C4MouseControl.h>
#include <C4PXS.h>
#include <C4GameMessage.h>
#endif
#include <StdGL.h>
@ -855,7 +856,7 @@ void C4Viewport::DrawOverlay(C4TargetFacet &cgo, const ZoomData &GameZoom)
}
// Game messages
C4ST_STARTNEW(MsgStat, "C4Viewport::DrawOverlay: Messages")
Game.Messages.Draw(cgo, Player, Zoom);
::Messages.Draw(cgo, Player, Zoom);
C4ST_STOP(MsgStat)
// Control overlays (if not film/replay)

View File

@ -111,33 +111,6 @@ void SoundPan(const char *szSndName, C4Object *pObj, int32_t iPan)
#define GfxR (&(::GraphicsResource))
//=============================== Messages =============================================
void GameMsgObject(const char *szText, C4Object *pTarget, int32_t iFCol)
{
Game.Messages.New(C4GM_Target,szText,pTarget,NO_OWNER,0,0,(uint8_t) iFCol);
}
void GameMsgObjectPlayer(const char *szText, C4Object *pTarget, int32_t iPlayer, int32_t iFCol)
{
Game.Messages.New(C4GM_TargetPlayer,szText,pTarget,iPlayer,0,0,(uint8_t) iFCol);
}
void GameMsgGlobal(const char *szText, int32_t iFCol)
{
Game.Messages.New(C4GM_Global,szText,NULL,ANY_OWNER,0,0,(uint8_t) iFCol);
}
void GameMsgPlayer(const char *szText, int32_t iPlayer, int32_t iFCol)
{
Game.Messages.New(C4GM_GlobalPlayer,szText,NULL,iPlayer,0,0,(uint8_t) iFCol);
}
void GameMsgObjectDw(const char *szText, C4Object *pTarget, uint32_t dwClr)
{
Game.Messages.New(C4GM_Target,szText,pTarget,NO_OWNER,0,0,dwClr);
}
//================================== Players ============================================
int32_t ValidPlr(int32_t plr)