Engine: Removed OSTR

Nicolas Hake 2009-05-11 15:09:53 +02:00
parent cbdbbed62a
commit 5e5184458c
40 changed files with 258 additions and 279 deletions

View File

@ -256,8 +256,6 @@ const int32_t C4P_Command_None = 0,
C4P_Command_Append = 4,
C4P_Command_Range = 8;
extern char OSTR[500];
//=================================== Owners ==============================================
const int NO_OWNER = -1,

View File

@ -363,8 +363,6 @@ const int32_t C4RULE_StructuresNeedEnergy = 1,
C4RULE_FlagRemoveable = 4,
C4RULE_StructuresSnowIn = 8;
extern char OSTR[500];
extern C4Game Game;
// a global wrapper

View File

@ -316,9 +316,9 @@ protected:
// handling of own packets
void HandleConn(const class C4PacketConn &Pkt, C4Network2IOConnection *pConn, C4Network2Client *pClient);
bool CheckConn(const C4ClientCore &CCore, C4Network2IOConnection *pConn, C4Network2Client *pClient, const char *&szReply);
bool HostConnect(const C4ClientCore &CCore, C4Network2IOConnection *pConn, const char *&szReply);
bool Join(C4ClientCore &CCore, C4Network2IOConnection *pConn, const char *&szReply);
bool CheckConn(const C4ClientCore &CCore, C4Network2IOConnection *pConn, C4Network2Client *pClient, const char *szReply);
bool HostConnect(const C4ClientCore &CCore, C4Network2IOConnection *pConn, const char *szReply);
bool Join(C4ClientCore &CCore, C4Network2IOConnection *pConn, const char *szReply);
void HandleConnRe(const class C4PacketConnRe &Pkt, C4Network2IOConnection *pConn, C4Network2Client *pClient);
void HandleStatus(const C4Network2Status &nStatus);
void HandleStatusAck(const C4Network2Status &nStatus, C4Network2Client *pClient);

View File

@ -266,9 +266,8 @@ void C4AulScriptEngine::Link(C4DefList *rDefs)
Game.Material.UpdateScriptPointers();
// display state
sprintf(OSTR, "C4AulScriptEngine linked - %d line%s, %d warning%s, %d error%s",
LogF("C4AulScriptEngine linked - %d line%s, %d warning%s, %d error%s",
lineCnt, (lineCnt != 1 ? "s" : ""), warnCnt, (warnCnt != 1 ? "s" : ""), errCnt, (errCnt != 1 ? "s" : ""));
Log(OSTR);
// reset counters
warnCnt = errCnt = nonStrictCnt = lineCnt = 0;

View File

@ -2044,14 +2044,13 @@ void C4Command::Fail(const char *szFailMessage)
char szCommandName[24 + 1];
char szObjectName[C4MaxName + 1];
StdStrBuf str;
if (ExecFail && cObj && (cObj->OCF & OCF_CrewMember))
{
// Fail message
if (szFailMessage)
SCopy(szFailMessage, OSTR, sizeof (OSTR) - 1);
else
OSTR[0]=0;
str = szFailMessage;
C4Object * l_Obj = cObj;
switch (Command)
{
@ -2063,7 +2062,7 @@ void C4Command::Fail(const char *szFailMessage)
C4VID(Target->Component.GetID(0)), C4VInt(Target->Component.GetCount(0))))) // WTF? This is passing current components. Not needed ones!
break; // no message
if (szFailMessage) break;
SCopy(Target->GetNeededMatStr(cObj).getData(), OSTR, sizeof(OSTR));
str = Target->GetNeededMatStr(cObj);
break;
case C4CMD_Call:
{
@ -2072,7 +2071,7 @@ void C4Command::Fail(const char *szFailMessage)
if (CallFailed()) return;
// Fail-function not available or returned zero: standard message
SCopy(LoadResStr(CommandNameID(l_Command)),szCommandName);
sprintf(OSTR,LoadResStr("IDS_CON_FAILURE"),szCommandName);
str.Format(LoadResStr("IDS_CON_FAILURE"),szCommandName);
break;
}
case C4CMD_Exit:
@ -2089,22 +2088,22 @@ void C4Command::Fail(const char *szFailMessage)
SCopy(LoadResStr(CommandNameID(Command)), szCommandName);
C4Def *pDef; pDef = Game.Defs.ID2Def(Data);
SCopy(pDef ? pDef->GetName() : LoadResStr("IDS_OBJ_UNKNOWN"), szObjectName);
sprintf(OSTR, LoadResStr("IDS_CON_FAILUREOF"), szCommandName, szObjectName);
str.Format(LoadResStr("IDS_CON_FAILUREOF"), szCommandName, szObjectName);
break;
default:
// Already has a fail message
if (szFailMessage) break;
// Standard no-can-do message
SCopy(LoadResStr(CommandNameID(Command)), szCommandName);
sprintf(OSTR, LoadResStr("IDS_CON_FAILURE"), szCommandName);
str.Format(LoadResStr("IDS_CON_FAILURE"), szCommandName);
break;
}
if (l_Obj) if (l_Obj->Status && !l_Obj->Def->SilentCommands)
{
// Message (if not empty)
if (OSTR[0])
if (!!str)
{
Game.Messages.Append(C4GM_Target, OSTR, l_Obj, NO_OWNER, 0, 0, FWhite, TRUE);
Game.Messages.Append(C4GM_Target, str.getData(), l_Obj, NO_OWNER, 0, 0, FWhite, TRUE);
}
// Fail sound
StartSoundEffect("CommandFailure*",false,100,l_Obj);

View File

@ -258,8 +258,8 @@ BOOL CALLBACK ConsoleDlgProc(HWND hDlg, UINT Msg, WPARAM wParam, LPARAM lParam)
// Remove player
if (Inside((int) LOWORD(wParam),IDM_PLAYER_QUIT1,IDM_PLAYER_QUIT2))
{
sprintf(OSTR, "EliminatePlayer(%d)", LOWORD(wParam)-IDM_PLAYER_QUIT1);
Game.Control.Input.Add(CID_Script, new C4ControlScript(OSTR));
Game.Control.Input.Add(CID_Script, new C4ControlScript(
FormatString("EliminatePlayer(%d)", LOWORD(wParam)-IDM_PLAYER_QUIT1).getData()));
return TRUE;
}
// Remove client
@ -680,24 +680,26 @@ bool C4Console::UpdateStatusBars()
if (Game.FrameCounter!=FrameCounter)
{
FrameCounter=Game.FrameCounter;
sprintf(OSTR,"Frame: %i",FrameCounter);
StdStrBuf str;
str.Format("Frame: %i",FrameCounter);
#ifdef _WIN32
SetDlgItemText(hWindow,IDC_STATICFRAME,OSTR);
SetDlgItemText(hWindow,IDC_STATICFRAME,str.getData());
UpdateWindow(GetDlgItem(hWindow,IDC_STATICFRAME));
#elif WITH_DEVELOPER_MODE
gtk_label_set_label(GTK_LABEL(lblFrame), OSTR);
gtk_label_set_label(GTK_LABEL(lblFrame), str.getData());
#endif // WITH_DEVELOPER_MODE / _WIN32
}
// Script counter
if (Game.Script.Counter!=ScriptCounter)
{
ScriptCounter=Game.Script.Counter;
sprintf(OSTR,"Script: %i",ScriptCounter);
StdStrBuf str;
str.Format("Script: %i",ScriptCounter);
#ifdef _WIN32
SetDlgItemText(hWindow,IDC_STATICSCRIPT,OSTR);
SetDlgItemText(hWindow,IDC_STATICSCRIPT,str.getData());
UpdateWindow(GetDlgItem(hWindow,IDC_STATICSCRIPT));
#elif WITH_DEVELOPER_MODE
gtk_label_set_label(GTK_LABEL(lblScript), OSTR);
gtk_label_set_label(GTK_LABEL(lblScript), str.getData());
#endif // WITH_DEVELOPER_MODE / _WIN32
}
// Time & FPS
@ -705,12 +707,13 @@ bool C4Console::UpdateStatusBars()
{
Time=Game.Time;
FPS=Game.FPS;
sprintf(OSTR,"%02d:%02d:%02d (%i FPS)",Time/3600,(Time%3600)/60,Time%60,FPS);
StdStrBuf str;
str.Format("%02d:%02d:%02d (%i FPS)",Time/3600,(Time%3600)/60,Time%60,FPS);
#ifdef _WIN32
SetDlgItemText(hWindow,IDC_STATICTIME,OSTR);
SetDlgItemText(hWindow,IDC_STATICTIME,str.getData());
UpdateWindow(GetDlgItem(hWindow,IDC_STATICTIME));
#elif WITH_DEVELOPER_MODE
gtk_label_set_label(GTK_LABEL(lblTime), OSTR);
gtk_label_set_label(GTK_LABEL(lblTime), str.getData());
#endif // WITH_DEVELOPER_MODE
}
return TRUE;
@ -751,9 +754,10 @@ BOOL C4Console::SaveGame(BOOL fSaveGame)
// Can't save to child groups
if (Game.ScenarioFile.GetMother())
{
sprintf(OSTR,LoadResStr("IDS_CNS_NOCHILDSAVE"),
StdStrBuf str;
str.Format(LoadResStr("IDS_CNS_NOCHILDSAVE"),
GetFilename(Game.ScenarioFile.GetName()));
Message(OSTR);
Message(str.getData());
return FALSE;
}
@ -791,9 +795,9 @@ BOOL C4Console::SaveGame(BOOL fSaveGame)
if (Game.fScriptCreatedObjects)
if (!fSaveGame)
{
SCopy(LoadResStr("IDS_CNS_SCRIPTCREATEDOBJECTS"),OSTR,sizeof(OSTR));
SAppend(LoadResStr("IDS_CNS_WARNDOUBLE"),OSTR,sizeof(OSTR));
Message(OSTR);
StdStrBuf str(LoadResStr("IDS_CNS_SCRIPTCREATEDOBJECTS"));
str += LoadResStr("IDS_CNS_WARNDOUBLE");
Message(str.getData());
Game.fScriptCreatedObjects=FALSE;
}
@ -840,8 +844,7 @@ BOOL C4Console::FileSaveAs(BOOL fSaveGame)
// Failure message
if (!fOkay)
{
sprintf(OSTR,LoadResStr("IDS_CNS_SAVEASERROR"),Game.ScenarioFilename);
Message(OSTR); return FALSE;
Message(FormatString(LoadResStr("IDS_CNS_SAVEASERROR"),Game.ScenarioFilename).getData()); return FALSE;
}
// Save game
return SaveGame(fSaveGame);
@ -1376,9 +1379,7 @@ void C4Console::UpdateInputCtrl()
if (pFn->GetPublic())
{
#ifdef _WIN32
SCopy(pFn->Name, OSTR);
SAppend("()",OSTR);
SendMessage(hCombo,CB_ADDSTRING,0,(LPARAM)OSTR);
SendMessage(hCombo,CB_ADDSTRING,0,(LPARAM)pFn->Name);
#else
#if WITH_DEVELOPER_MODE
gtk_list_store_append(store, &iter);
@ -1394,9 +1395,7 @@ void C4Console::UpdateInputCtrl()
for (cnt=0; pRef=Game.Script.GetSFunc(cnt); cnt++)
{
#ifdef _WIN32
SCopy(pRef->Name,OSTR);
SAppend("()",OSTR);
SendMessage(hCombo,CB_INSERTSTRING,0,(LPARAM)OSTR);
SendMessage(hCombo,CB_INSERTSTRING,0,(LPARAM)pRef->Name);
#elif WITH_DEVELOPER_MODE
gtk_list_store_append(store, &iter);
gtk_list_store_set(store, &iter, 0, pRef->Name, -1);
@ -1562,23 +1561,24 @@ void C4Console::UpdateNetMenu()
#endif
// Host
sprintf(OSTR,LoadResStr("IDS_MNU_NETHOST"),Game.Clients.getLocalName(),Game.Clients.getLocalID());
StdStrBuf str;
str.Format(LoadResStr("IDS_MNU_NETHOST"),Game.Clients.getLocalName(),Game.Clients.getLocalID());
#ifdef _WIN32
AddMenuItem(hMenu,IDM_NET_CLIENT1+Game.Clients.getLocalID(),OSTR);
AddMenuItem(hMenu,IDM_NET_CLIENT1+Game.Clients.getLocalID(),str.getData());
#elif WITH_DEVELOPER_MODE
GtkWidget* item = gtk_menu_item_new_with_label(OSTR);
GtkWidget* item = gtk_menu_item_new_with_label(str.getData());
gtk_menu_shell_append(GTK_MENU_SHELL(menuNet), item);
g_signal_connect(G_OBJECT(item), "activate", G_CALLBACK(OnNetClient), GINT_TO_POINTER(Game.Clients.getLocalID()));
#endif
// Clients
for (C4Network2Client *pClient=Game.Network.Clients.GetNextClient(NULL); pClient; pClient=Game.Network.Clients.GetNextClient(pClient))
{
sprintf(OSTR, LoadResStr(pClient->isActivated() ? "IDS_MNU_NETCLIENT" : "IDS_MNU_NETCLIENTDE"),
pClient->getName(), pClient->getID());
str.Format(LoadResStr(pClient->isActivated() ? "IDS_MNU_NETCLIENT" : "IDS_MNU_NETCLIENTDE"),
pClient->getName(), pClient->getID());
#ifdef _WIN32
AddMenuItem(hMenu,IDM_NET_CLIENT1+pClient->getID(),OSTR);
AddMenuItem(hMenu,IDM_NET_CLIENT1+pClient->getID(), str.getData());
#elif WITH_DEVELOPER_MODE
item = gtk_menu_item_new_with_label(OSTR);
item = gtk_menu_item_new_with_label(str.getData());
gtk_menu_shell_append(GTK_MENU_SHELL(menuNet), item);
g_signal_connect(G_OBJECT(item), "activate", G_CALLBACK(OnNetClient), GINT_TO_POINTER(pClient->getID()));
#endif

View File

@ -147,8 +147,7 @@ void C4ControlSet::Execute() const
if (Game.Control.isCtrlHost() && !Game.Control.isReplay() && Game.Control.isNetwork())
Config.Network.ControlRate = Game.Control.ControlRate;
// always show msg
sprintf(OSTR,LoadResStr("IDS_NET_CONTROLRATE"),Game.Control.ControlRate,Game.FrameCounter);
Game.GraphicsSystem.FlashMessage(OSTR);
Game.GraphicsSystem.FlashMessage(FormatString(LoadResStr("IDS_NET_CONTROLRATE"),Game.Control.ControlRate,Game.FrameCounter).getData());
break;
case C4CVT_AllowDebug: // allow debug mode?
@ -1030,6 +1029,7 @@ void C4ControlMessage::Execute() const
//if (pPlr) pPlr->CountControl(C4Player::PCID_Message, Message.GetHash());
// get lobby to forward to
C4GameLobby::MainDlg *pLobby = Game.Network.GetLobby();
StdStrBuf str;
switch(eType)
{
case C4CMT_Normal:
@ -1038,21 +1038,21 @@ void C4ControlMessage::Execute() const
if(pPlr)
{
if(pPlr->AtClient != iByClient) break;
sprintf(OSTR, (eType == C4CMT_Normal ? "<c %x><<i></i>%s> %s</c>" : "<c %x> * %s %s</c>"),
str.Format((eType == C4CMT_Normal ? "<c %x><<i></i>%s> %s</c>" : "<c %x> * %s %s</c>"),
pPlr->ColorDw, pPlr->GetName(), szMessage);
}
else
{
C4Client *pClient = Game.Clients.getClientByID(iByClient);
sprintf(OSTR, (eType == C4CMT_Normal ? "<%s> %s" : " * %s %s"),
str.Format((eType == C4CMT_Normal ? "<%s> %s" : " * %s %s"),
pClient ? pClient->getNick() : "???", szMessage);
}
// 2 lobby
if (pLobby)
pLobby->OnMessage(Game.Clients.getClientByID(iByClient), OSTR);
pLobby->OnMessage(Game.Clients.getClientByID(iByClient), str.getData());
// or 2 log
else
Log(OSTR);
Log(str.getData());
break;
case C4CMT_Say:

View File

@ -603,8 +603,7 @@ BOOL C4Def::Load(C4Group &hGroup,
#ifdef C4ENGINE // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
// wie geth ID?????ßßßß
if (!Name[0]) Name = GetFilename(hGroup.GetName());
sprintf(OSTR, LoadResStr("IDS_ERR_INVALIDID"), Name.getData());
Log(OSTR);
LogF(LoadResStr("IDS_ERR_INVALIDID"), Name.getData());
#endif // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
fSuccess=FALSE;
}
@ -887,7 +886,7 @@ BOOL C4Def::ColorizeByMaterial(C4MaterialMap &rMats, BYTE bGBM)
if (ColorByMaterial[0])
{
int32_t mat=rMats.Get(ColorByMaterial);
if (mat==MNone) { sprintf(OSTR, "C4Def::ColorizeByMaterial: mat %s not defined", ColorByMaterial); Log(OSTR); return FALSE; }
if (mat==MNone) { LogF("C4Def::ColorizeByMaterial: mat %s not defined", ColorByMaterial); return FALSE; }
if (!Graphics.ColorizeByMaterial(mat, rMats, bGBM)) return FALSE;
}
#endif // - - - - - - - - - - - - - - - - - - - - - - - - - - -
@ -1015,7 +1014,7 @@ int32_t C4DefList::Load(C4Group &hGroup, DWORD dwLoadWhat,
}
#ifdef C4ENGINE // Message - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
if (fThisSearchMessage) { sprintf(OSTR,"%s...",GetFilename(hGroup.GetName())); Log(OSTR); }
if (fThisSearchMessage) { LogF("%s...",GetFilename(hGroup.GetName())); }
#endif // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
// Load primary definition
@ -1064,7 +1063,7 @@ int32_t C4DefList::Load(C4Group &hGroup, DWORD dwLoadWhat,
#endif
#ifdef C4ENGINE // Message - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
if (fThisSearchMessage) { sprintf(OSTR,LoadResStr("IDS_PRC_DEFSLOADED"),iResult); Log(OSTR); }
if (fThisSearchMessage) { LogF(LoadResStr("IDS_PRC_DEFSLOADED"),iResult); }
// progress (could go down one level of recursion...)
if (iMinProgress != iMaxProgress) Game.SetInitProgress(float(iMaxProgress));

View File

@ -682,6 +682,7 @@ void C4GraphicsOverlay::Read(const char **ppInput)
{
// deprecated
assert(false && "C4GraphicsOverlay::Read: deprecated");
#if 0
const char *szReadFrom = *ppInput;
// defaults
eMode = MODE_None; pSourceGfx = NULL; *Action=0; dwBlitMode = 0; iPhase = 0; iID=0;
@ -735,12 +736,14 @@ void C4GraphicsOverlay::Read(const char **ppInput)
*ppInput = szReadFrom;
// update used facet according to read data
UpdateFacet();
#endif
}
void C4GraphicsOverlay::Write(char *szOutput)
{
// deprecated
assert(false && "C4GraphicsOverlay::Write: deprecated");
#if 0
// safety: Don't save invalid
if (!pSourceGfx) return;
C4Def *pDef = pSourceGfx->pDef;
@ -776,6 +779,7 @@ void C4GraphicsOverlay::Write(char *szOutput)
SCopy(OSTR, szOutput); szOutput += strlen(szOutput);
// terminate string
*szOutput=0;
#endif
}
void C4GraphicsOverlay::CompileFunc(StdCompiler *pComp)

View File

@ -173,24 +173,24 @@ bool C4EditCursor::Move(float iX, float iY, WORD wKeyFlags)
BOOL C4EditCursor::UpdateStatusBar()
{
*OSTR='\0';
StdStrBuf str;
switch (Mode)
{
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
case C4CNS_ModePlay:
if (Game.MouseControl.GetCaption()) SCopyUntil(Game.MouseControl.GetCaption(),OSTR,'|');
if (Game.MouseControl.GetCaption()) str.CopyUntil(Game.MouseControl.GetCaption(),'|');
break;
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
case C4CNS_ModeEdit:
sprintf(OSTR,"%i/%i (%s)",X,Y,Target ? (Target->GetName()) : LoadResStr("IDS_CNS_NOTHING") );
str.Format("%i/%i (%s)",X,Y,Target ? (Target->GetName()) : LoadResStr("IDS_CNS_NOTHING") );
break;
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
case C4CNS_ModeDraw:
sprintf(OSTR,"%i/%i (%s)",X,Y,MatValid(GBackMat(X,Y)) ? Game.Material.Map[GBackMat(X,Y)].Name : LoadResStr("IDS_CNS_NOTHING") );
str.Format("%i/%i (%s)",X,Y,MatValid(GBackMat(X,Y)) ? Game.Material.Map[GBackMat(X,Y)].Name : LoadResStr("IDS_CNS_NOTHING") );
break;
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
}
return Console.UpdateCursorBar(OSTR);
return Console.UpdateCursorBar(str.getData());
}
void C4EditCursor::OnSelectionChanged()
@ -693,8 +693,7 @@ void C4EditCursor::ToolFailure()
{
C4ToolsDlg *pTools=&Console.ToolsDlg;
Hold=FALSE;
sprintf(OSTR,LoadResStr("IDS_CNS_NOMATDEF"),pTools->Material,pTools->Texture);
Console.Message(OSTR);
Console.Message(FormatString(LoadResStr("IDS_CNS_NOMATDEF"),pTools->Material,pTools->Texture).getData());
}
void C4EditCursor::ApplyToolPicker()

View File

@ -54,8 +54,6 @@
#include <StdFile.h>
char OSTR[500];
class C4GameSec1Timer : public C4ApplicationSec1Timer
{
public:
@ -1560,32 +1558,31 @@ BOOL C4Game::DropFile(const char *szFilename, float iX, float iY)
return DropDef(c_id, iX, iY);
}
// Failure
sprintf(OSTR,LoadResStr("IDS_CNS_DROPNODEF"),GetFilename(szFilename));
Console.Out(OSTR);
Console.Out(FormatString(LoadResStr("IDS_CNS_DROPNODEF"),GetFilename(szFilename)).getData());
return FALSE;
}
return FALSE;
}
BOOL C4Game::DropDef(C4ID id, float iX, float iY)
BOOL C4Game::DropDef(C4ID id, float X, float Y)
{
// Get def
C4Def *pDef;
if (pDef=C4Id2Def(id))
{
StdStrBuf str;
if (pDef->Category & C4D_Structure)
sprintf(OSTR, "CreateConstruction(%s,%d,%d,-1,%d,true)", C4IdText(id), int(iX), int(iY), FullCon);
str.Format("CreateConstruction(%s,%d,%d,-1,%d,true)", C4IdText(id), int(X), int(Y), FullCon);
else
sprintf(OSTR, "CreateObject(%s,%d,%d,-1)", C4IdText(id), int(iX), int(iY));
Game.Control.DoInput(CID_Script, new C4ControlScript(OSTR), CDT_Decide);
return TRUE;
str.Format("CreateObject(%s,%d,%d,-1)", C4IdText(id), int(X), int(Y));
Game.Control.DoInput(CID_Script, new C4ControlScript(str.getData()), CDT_Decide);
return TRUE;
}
else
{
// Failure
Console.Out(FormatString(LoadResStr("IDS_CNS_DROPNODEF"),C4IdText(id)).getData());
}
else
{
// Failure
sprintf(OSTR,LoadResStr("IDS_CNS_DROPNODEF"),C4IdText(id));
Console.Out(OSTR);
}
return FALSE;
}
@ -1762,14 +1759,15 @@ void C4Game::DrawCursors(C4TargetFacet &cgo, int32_t iPlayer)
if (cursor->Info)
{
int32_t texthgt = Game.GraphicsResource.FontRegular.iLineHgt;
StdStrBuf str;
if (cursor->Info->Rank>0)
{
sprintf(OSTR,"%s|%s",cursor->Info->sRankName.getData(),cursor->GetName ());
str.Format("%s|%s",cursor->Info->sRankName.getData(),cursor->GetName ());
texthgt += texthgt;
}
else SCopy(cursor->GetName (),OSTR);
else str = cursor->GetName();
Application.DDraw->TextOut(OSTR, Game.GraphicsResource.FontRegular, 1.0, cgo.Surface,
Application.DDraw->TextOut(str.getData(), Game.GraphicsResource.FontRegular, 1.0, cgo.Surface,
cgo.X + cox + fctCursor.Wdt / 2,
cgo.Y + coy - 2 - texthgt,
0xffff0000, ACenter);
@ -2158,7 +2156,7 @@ BOOL C4Game::ReloadDef(C4ID id)
C4Def *pDef = Defs.ID2Def(id);
if (!pDef) return FALSE;
// Message
sprintf(OSTR,"Reloading %s from %s",C4IdText(pDef->id),GetFilename(pDef->Filename)); Log(OSTR);
LogF("Reloading %s from %s",C4IdText(pDef->id),GetFilename(pDef->Filename));
// Reload def
if (Defs.Reload(pDef,C4D_Load_RX,Config.General.LanguageEx,&Application.SoundSystem))
{
@ -2202,7 +2200,7 @@ BOOL C4Game::ReloadParticle(const char *szName)
C4ParticleDef *pDef=Particles.GetDef(szName);
if (!pDef) return FALSE;
// verbose
sprintf(OSTR,"Reloading particle %s from %s",pDef->Name.getData(),GetFilename(pDef->Filename.getData())); Log(OSTR);
LogF("Reloading particle %s from %s",pDef->Name.getData(),GetFilename(pDef->Filename.getData()));
// reload it
if (!pDef->Reload())
{
@ -2211,7 +2209,7 @@ BOOL C4Game::ReloadParticle(const char *szName)
// clear def
delete pDef;
// log
sprintf(OSTR,"Reloading failure. All particles removed."); Log(OSTR);
LogF("Reloading failure. All particles removed.");
// failure
return FALSE;
}
@ -2541,8 +2539,7 @@ BOOL C4Game::InitPlayers()
if (iPlrCnt==0)
if (Application.isFullScreen && !Control.NoInput())
{
sprintf(OSTR,LoadResStr("IDS_CNS_NOFULLSCREENPLRS"));
LogFatal(OSTR); return FALSE;
LogFatal(LoadResStr("IDS_CNS_NOFULLSCREENPLRS")); return FALSE;
}
#endif
// Too many players
@ -3642,8 +3639,8 @@ BOOL C4Game::CheckObjectEnumeration()
cObj = clnk->Obj;
if (cObj->Number<1)
{
sprintf(OSTR, "Invalid object enumeration number (%d) of object %s (x=%d)", cObj->Number, C4IdText(cObj->id), cObj->GetX());
Log(OSTR); return FALSE;
LogF("Invalid object enumeration number (%d) of object %s (x=%d)", cObj->Number, C4IdText(cObj->id), cObj->GetX());
return FALSE;
}
// Max
if (cObj->Number>iMax) iMax=cObj->Number;
@ -3651,11 +3648,11 @@ BOOL C4Game::CheckObjectEnumeration()
for (clnk2=Objects.First; clnk2 && (cObj2=clnk2->Obj); clnk2=clnk2->Next)
if (cObj2!=cObj)
if (cObj->Number==cObj2->Number)
{ sprintf(OSTR,"Duplicate object enumeration number %d (%s and %s)",cObj2->Number,cObj->GetName(),cObj2->GetName()); Log(OSTR); return FALSE; }
{ LogF("Duplicate object enumeration number %d (%s and %s)",cObj2->Number,cObj->GetName(),cObj2->GetName()); return FALSE; }
for (clnk2=Objects.InactiveObjects.First; clnk2 && (cObj2=clnk2->Obj); clnk2=clnk2->Next)
if (cObj2!=cObj)
if (cObj->Number==cObj2->Number)
{ sprintf(OSTR,"Duplicate object enumeration number %d (%s and %s(i))",cObj2->Number,cObj->GetName(),cObj2->GetName()); Log(OSTR); return FALSE; }
{ LogF("Duplicate object enumeration number %d (%s and %s(i))",cObj2->Number,cObj->GetName(),cObj2->GetName()); return FALSE; }
// next
if (!clnk->Next)
if (clnk == Objects.Last) clnk=Objects.InactiveObjects.First; else clnk=NULL;
@ -4073,8 +4070,7 @@ bool C4Game::SpeedUp()
// Use /fast to set to even higher speeds.
FrameSkip = BoundBy<int32_t>(FrameSkip + 1, 1, 50);
FullSpeed = TRUE;
sprintf(OSTR, LoadResStr("IDS_MSG_SPEED"), FrameSkip);
GraphicsSystem.FlashMessage(OSTR);
GraphicsSystem.FlashMessage(FormatString(LoadResStr("IDS_MSG_SPEED"), FrameSkip).getData());
return true;
}
@ -4083,8 +4079,7 @@ bool C4Game::SlowDown()
FrameSkip = BoundBy<int32_t>(FrameSkip - 1, 1, 50);
if (FrameSkip == 1)
FullSpeed = FALSE;
sprintf(OSTR, LoadResStr("IDS_MSG_SPEED"), FrameSkip);
GraphicsSystem.FlashMessage(OSTR);
GraphicsSystem.FlashMessage(FormatString(LoadResStr("IDS_MSG_SPEED"), FrameSkip).getData());
return true;
}

View File

@ -447,8 +447,7 @@ void C4GameControlNetwork::CalcPerformance(int32_t iCtrlTick)
if (getControlPreSend() != iBestPreSend)
{
setControlPreSend(iBestPreSend);
sprintf(OSTR, "PreSend: %d - TargetFPS: %d", iBestPreSend, iTargetFPS);
Game.GraphicsSystem.FlashMessage(OSTR);
Game.GraphicsSystem.FlashMessage(FormatString("PreSend: %d - TargetFPS: %d", iBestPreSend, iTargetFPS).getData());
}
}
}

View File

@ -477,8 +477,7 @@ C4GUI::Edit::InputResult MainDlg::OnChatInput(C4GUI::Edit *edt, bool fPasting, b
// player join - check filename
if (!ItemExists(plrPath.getData()))
{
sprintf(OSTR, LoadResStr("IDS_MSG_CMD_JOINPLR_NOFILE"), plrPath.getData());
LobbyError(OSTR);
LobbyError(FormatString(LoadResStr("IDS_MSG_CMD_JOINPLR_NOFILE"), plrPath.getData()).getData());
}
else
Game.Network.Players.JoinLocalPlayer(plrPath.getData(), true);

View File

@ -452,7 +452,7 @@ bool C4GameSave::Save(C4Group &hToGroup, bool fKeepGroup)
{
pSaveGroup->Delete(C4CFN_ScenarioTitle);
pSaveGroup->Delete(C4CFN_ScenarioIcon);
sprintf(OSTR,C4CFN_ScenarioDesc,"*"); pSaveGroup->Delete(OSTR);
pSaveGroup->Delete(FormatString(C4CFN_ScenarioDesc,"*").getData());
pSaveGroup->Delete(C4CFN_Titles);
pSaveGroup->Delete(C4CFN_Info);
}

View File

@ -602,10 +602,9 @@ bool C4GraphicsSystem::SaveScreenshot(bool fSaveAll)
BOOL fSuccess=DoSaveScreenshot(fSaveAll, strFilePath);
// log if successful/where it has been stored
if (!fSuccess)
sprintf(OSTR, LoadResStr("IDS_PRC_SCREENSHOTERROR"), Config.AtUserDataRelativePath(Config.AtScreenshotPath(szFilename)));
LogF(LoadResStr("IDS_PRC_SCREENSHOTERROR"), Config.AtUserDataRelativePath(Config.AtScreenshotPath(szFilename)));
else
sprintf(OSTR, LoadResStr("IDS_PRC_SCREENSHOT"), Config.AtUserDataRelativePath(Config.AtScreenshotPath(szFilename)));
Log(OSTR);
LogF(LoadResStr("IDS_PRC_SCREENSHOT"), Config.AtUserDataRelativePath(Config.AtScreenshotPath(szFilename)));
// return success
return !!fSuccess;
}

View File

@ -1356,9 +1356,8 @@ bool C4Group::RewindFilePtr()
#ifdef C4ENGINE
if (szCurrAccessedEntry && !iC4GroupRewindFilePtrNoWarn)
{
sprintf (OSTR, "C4Group::RewindFilePtr() for %s (%s)", szCurrAccessedEntry ? szCurrAccessedEntry : "???", FileName);
LogF ("C4Group::RewindFilePtr() for %s (%s)", szCurrAccessedEntry ? szCurrAccessedEntry : "???", FileName);
szCurrAccessedEntry=NULL;
Log(OSTR);
}
#endif
#endif

View File

@ -1060,7 +1060,7 @@ void ConfirmationDialog::OnClosed(bool fOK)
// ProgressDialog
ProgressDialog::ProgressDialog(const char *szMessage, const char *szCaption, int32_t iMaxProgress, int32_t iInitialProgress, Icons icoIcon)
: Dialog(C4GUI_ProgressDlgWdt, Max(GetRes()->TextFont.BreakMessage(szMessage, C4GUI_ProgressDlgWdt-3*C4GUI_DefDlgIndent-C4GUI_IconWdt, OSTR, 4096, true), C4GUI_IconHgt) + C4GUI_ProgressDlgVRoom, szCaption, false)
: Dialog(C4GUI_ProgressDlgWdt, Max(GetRes()->TextFont.BreakMessage(szMessage, C4GUI_ProgressDlgWdt-3*C4GUI_DefDlgIndent-C4GUI_IconWdt, 0, 0, true), C4GUI_IconHgt) + C4GUI_ProgressDlgVRoom, szCaption, false)
{
// get positions
ComponentAligner caMain(GetClientRect(), C4GUI_DefDlgIndent, C4GUI_DefDlgIndent, true);
@ -1071,7 +1071,9 @@ ProgressDialog::ProgressDialog(const char *szMessage, const char *szCaption, int
Icon *pIcon = new Icon(rcIcon, icoIcon); AddElement(pIcon);
// place message label
// use text with line breaks
Label *pLblMessage = new Label(OSTR, caMain.GetAll().GetMiddleX(), caMain.GetAll().y, ACenter, C4GUI_MessageFontClr, &GetRes()->TextFont);
StdStrBuf str;
GetRes()->TextFont.BreakMessage(szMessage, C4GUI_ProgressDlgWdt-3*C4GUI_DefDlgIndent-C4GUI_IconWdt, &str, true);
Label *pLblMessage = new Label(str.getData(), caMain.GetAll().GetMiddleX(), caMain.GetAll().y, ACenter, C4GUI_MessageFontClr, &GetRes()->TextFont);
AddElement(pLblMessage);
// place progress bar
pBar = new ProgressBar(rtProgressBar, iMaxProgress);
@ -1166,7 +1168,7 @@ bool Screen::ShowRemoveDlg(Dialog *pDlg)
InputDialog::InputDialog(const char *szMessage, const char *szCaption, Icons icoIcon, BaseInputCallback *pCB, bool fChatLayout)
: Dialog(fChatLayout ? C4GUI::GetScreenWdt()*4/5 : C4GUI_InputDlgWdt,
fChatLayout ? C4GUI::Edit::GetDefaultEditHeight() + 2 :
Max(GetRes()->TextFont.BreakMessage(szMessage, C4GUI_InputDlgWdt - 3 * C4GUI_DefDlgIndent - C4GUI_IconWdt, OSTR, 4096, true),
Max(GetRes()->TextFont.BreakMessage(szMessage, C4GUI_InputDlgWdt - 3 * C4GUI_DefDlgIndent - C4GUI_IconWdt, 0, 0, true),
C4GUI_IconHgt) + C4GUI_InputDlgVRoom, szCaption, false),
pEdit(NULL), pChatLbl(NULL), pCB(pCB), fChatLayout(fChatLayout)
{
@ -1196,7 +1198,9 @@ pEdit(NULL), pChatLbl(NULL), pCB(pCB), fChatLayout(fChatLayout)
Icon *pIcon = new Icon(rcIcon, icoIcon); AddElement(pIcon);
// place message label
// use text with line breaks
Label *pLblMessage = new Label(OSTR, caMain.GetAll().GetMiddleX(), caMain.GetAll().y, ACenter, C4GUI_MessageFontClr, &GetRes()->TextFont);
StdStrBuf str;
GetRes()->TextFont.BreakMessage(szMessage, C4GUI_InputDlgWdt - 3 * C4GUI_DefDlgIndent - C4GUI_IconWdt, &str, true);
Label *pLblMessage = new Label(str.getData(), caMain.GetAll().GetMiddleX(), caMain.GetAll().y, ACenter, C4GUI_MessageFontClr, &GetRes()->TextFont);
AddElement(pLblMessage);
// place input edit
SetCustomEdit(new Edit(rcEditBounds));

View File

@ -2072,16 +2072,14 @@ BOOL ConstructionCheck(C4ID id, int32_t iX, int32_t iY, C4Object *pByObj)
if (!(ndef=C4Id2Def(id)))
{
GetC4IdText(id,idostr);
sprintf(OSTR,LoadResStr("IDS_OBJ_UNDEF"),idostr);
if (pByObj) GameMsgObject(OSTR,pByObj,FRed);
if (pByObj) GameMsgObject(FormatString(LoadResStr("IDS_OBJ_UNDEF"),idostr).getData(),pByObj,FRed);
return FALSE;
}
// Constructable?
if (!ndef->Constructable)
{
sprintf(OSTR,LoadResStr("IDS_OBJ_NOCON"),ndef->GetName());
if (pByObj) GameMsgObject(OSTR,pByObj,FRed);
if (pByObj) GameMsgObject(FormatString(LoadResStr("IDS_OBJ_NOCON"),ndef->GetName()).getData(),pByObj,FRed);
return FALSE;
}
@ -2104,8 +2102,7 @@ BOOL ConstructionCheck(C4ID id, int32_t iX, int32_t iY, C4Object *pByObj)
C4Object *other;
if (other=Game.OverlapObject(rtx,rty,wdt,hgt,ndef->Category))
{
sprintf(OSTR,LoadResStr("IDS_OBJ_NOOTHER"),other->GetName ());
if (pByObj) GameMsgObject(OSTR,pByObj,FRed);
if (pByObj) GameMsgObject(FormatString(LoadResStr("IDS_OBJ_NOOTHER"),other->GetName ()).getData(),pByObj,FRed);
return FALSE;
}

View File

@ -94,7 +94,7 @@ void C4LangStringTable::ReplaceStrings(const StdStrBuf &rBuf, StdStrBuf &rTarget
}
// found?
if(!pStrTblEntry)
{ sprintf(OSTR, "%s: string table entry not found: \"%s\"", FilePath[0] ? FilePath : (szParentFilePath ? szParentFilePath : "Unknown"), szStringName); Log(OSTR); continue; }
{ LogF("%s: string table entry not found: \"%s\"", FilePath[0] ? FilePath : (szParentFilePath ? szParentFilePath : "Unknown"), szStringName); continue; }
// add new replace-position entry
RP *pnRP = new RP;
pnRP->Pos = pPos - SLen(szStringName) - 2;

View File

@ -191,8 +191,9 @@ void C4LoaderScreen::Draw(C4Facet &cgo, int iProgress, C4LogBuffer *pLog, int Pr
{
Application.DDraw->DrawBoxDw(cgo.Surface, iHIndent+1, cgo.Hgt-iVIndent-iLogBoxHgt-iVMargin-iProgressBarHgt+1, iHIndent+1+iProgressBarWdt*iProgress/100, cgo.Hgt-iVIndent-iLogBoxHgt-iVMargin-1, 0x4fff0000);
}
sprintf(OSTR, "%i%%", iProgress);
Application.DDraw->StringOut(OSTR, rProgressBarFont, 1.0f, cgo.Surface, cgo.Wdt/2, cgo.Hgt-iVIndent-iLogBoxHgt-iVMargin-rProgressBarFont.iLineHgt/2-iProgressBarHgt/2, 0xffffffff, ACenter, true);
Application.DDraw->StringOut(FormatString("%i%%", iProgress).getData(), rProgressBarFont, 1.0f, cgo.Surface,
cgo.Wdt/2, cgo.Hgt-iVIndent-iLogBoxHgt-iVMargin-rProgressBarFont.iLineHgt/2-iProgressBarHgt/2, 0xffffffff,
ACenter, true);
// draw log box
if (pLog)
{

View File

@ -1563,8 +1563,7 @@ bool AlgoScript(C4MCOverlay *pOvrl, int32_t iX, int32_t iY)
{
#ifdef C4ENGINE
// get script function
sprintf(OSTR, "ScriptAlgo%s", pOvrl->Name);
C4AulFunc *pFunc = Game.Script.GetSFunc(OSTR);
C4AulFunc *pFunc = Game.Script.GetSFunc(FormatString("ScriptAlgo%s", pOvrl->Name).getData());
// failsafe
if(!pFunc) return false;
// ok, call func

View File

@ -366,13 +366,15 @@ C4Player* C4MessageBoard::GetMessagePlayer(const char *szMessage)
// Scan message text for heading player name
if(SEqual2(szMessage, "* "))
{
SCopyUntil(szMessage + 2,OSTR,' ');
return Game.Players.GetByName(OSTR);
StdStrBuf str;
str.CopyUntil(szMessage + 2,' ');
return Game.Players.GetByName(str.getData());
}
if (SCharCount(':',szMessage))
{
SCopyUntil(szMessage,OSTR,':');
return Game.Players.GetByName(OSTR);
StdStrBuf str;
str.CopyUntil(szMessage + 2,':');
return Game.Players.GetByName(str.getData());
}
return NULL;
}

View File

@ -327,6 +327,7 @@ bool C4MessageInput::IsTypeIn()
bool C4MessageInput::ProcessInput(const char *szText)
{
// helper variables
char OSTR[402]; // cba
C4ControlMessageType eMsgType;
const char *szMsg = NULL;
int32_t iToPlayer = -1;
@ -386,6 +387,7 @@ bool C4MessageInput::ProcessInput(const char *szText)
{
eMsgType = C4CMT_Say;
// Append '"', if neccessary
StdStrBuf text(szText);
SCopy(szText, OSTR, 400);
char *pEnd = OSTR + SLen(OSTR) - 1;
if(*pEnd != '"') { *++pEnd = '"'; *++pEnd = 0; }

View File

@ -116,8 +116,7 @@ BOOL C4Object::Contact(int32_t iCNAT)
{
if (Def->ContactFunctionCalls)
{
sprintf(OSTR,PSF_Contact, CNATName(iCNAT));
return !! Call(OSTR);
return !! Call(FormatString(PSF_Contact, CNATName(iCNAT)).getData());
}
return FALSE;
}

View File

@ -110,8 +110,7 @@ BOOL C4MusicFileMID::Play(BOOL loop)
if (!mod)
{
sprintf(OSTR, "FMod: %s", FMOD_ErrorString(FSOUND_GetError()));
Log(OSTR);
LogF("FMod: %s", FMOD_ErrorString(FSOUND_GetError()));
return FALSE;
}
@ -168,8 +167,7 @@ BOOL C4MusicFileMOD::Play(BOOL loop)
if (!mod)
{
sprintf(OSTR, "FMod: %s", FMOD_ErrorString(FSOUND_GetError()));
Log(OSTR);
LogF("FMod: %s", FMOD_ErrorString(FSOUND_GetError()));
return FALSE;
}

View File

@ -82,14 +82,12 @@ bool C4MusicSystem::InitializeMOD()
#endif
if (FSOUND_GetVersion() < FMOD_VERSION)
{
sprintf(OSTR, "FMod: You are using the wrong DLL version! You should be using %.02f", FMOD_VERSION);
Log(OSTR);
LogF("FMod: You are using the wrong DLL version! You should be using %.02f", FMOD_VERSION);
return FALSE;
}
if (!FSOUND_Init(44100, 32, 0))
{
sprintf(OSTR, "FMod: %s", FMOD_ErrorString(FSOUND_GetError()));
Log(OSTR);
LogF("FMod: %s", FMOD_ErrorString(FSOUND_GetError()));
return FALSE;
}
// ok

View File

@ -1052,7 +1052,7 @@ void C4Network2::HandleConn(const C4PacketConn &Pkt, C4Network2IOConnection *pCo
C4ClientCore NewCCore = CCore;
// accept connection?
const char *szReply = NULL;
StdStrBuf reply;
bool fOK = false;
// search client
@ -1063,25 +1063,24 @@ void C4Network2::HandleConn(const C4PacketConn &Pkt, C4Network2IOConnection *pCo
bool fWrongPassword = false;
if(Pkt.getVer() != C4XVERBUILD)
{
sprintf(OSTR, "wrong engine (%d, I have %d)", Pkt.getVer(), C4XVERBUILD);
szReply = OSTR;
reply.Format("wrong engine (%d, I have %d)", Pkt.getVer(), C4XVERBUILD);
fOK = false;
}
else
{
if(pClient)
if(CheckConn(NewCCore, pConn, pClient, szReply))
if(CheckConn(NewCCore, pConn, pClient, reply.getData()))
{
// accept
if(!szReply) szReply = "connection accepted";
if(!reply) reply = "connection accepted";
fOK = true;
}
// client: host connection?
if(!fOK && !isHost() && Status.getState() == GS_Init && !Clients.GetHost())
if(HostConnect(NewCCore, pConn, szReply))
if(HostConnect(NewCCore, pConn, reply.getData()))
{
// accept
if(!szReply) szReply = "host connection accepted";
if(!reply) reply = "host connection accepted";
fOK = true;
}
// host: client join? (NewCCore will be changed by Join()!)
@ -1090,35 +1089,35 @@ void C4Network2::HandleConn(const C4PacketConn &Pkt, C4Network2IOConnection *pCo
// check password
if(!sPassword.isNull() && !SEqual(Pkt.getPassword(), sPassword.getData()))
{
szReply = "wrong password";
reply = "wrong password";
fWrongPassword = true;
}
// registered join only
else if (Game.RegJoinOnly && !SLen(NewCCore.getCUID()))
{
szReply = "registered join only";
reply = "registered join only";
}
// accept join
else if(Join(NewCCore, pConn, szReply))
else if(Join(NewCCore, pConn, reply.getData()))
{
// save core
pConn->SetCCore(NewCCore);
// accept
if(!szReply) szReply = "join accepted";
if(!reply) reply = "join accepted";
fOK = true;
}
}
}
// denied? set default reason
if(!fOK && !szReply) szReply = "connection denied";
if(!fOK && !reply) reply = "connection denied";
// OK and already half accepted? Skip (double-checked: ok).
if(fOK && pConn->isHalfAccepted())
return;
// send answer
C4PacketConnRe pcr(fOK, fWrongPassword, szReply);
C4PacketConnRe pcr(fOK, fWrongPassword, reply.getData());
if(!pConn->Send(MkC4NetIOPacket(PID_ConnRe, pcr)))
return;
@ -1133,12 +1132,12 @@ void C4Network2::HandleConn(const C4PacketConn &Pkt, C4Network2IOConnection *pCo
else
{
// log & close
LogSilentF("Network: connection by %s (%s:%d) blocked: %s", CCore.getName(), inet_ntoa(pConn->getPeerAddr().sin_addr), htons(pConn->getPeerAddr().sin_port), szReply ? szReply : "");
LogSilentF("Network: connection by %s (%s:%d) blocked: %s", CCore.getName(), inet_ntoa(pConn->getPeerAddr().sin_addr), htons(pConn->getPeerAddr().sin_port), reply.getData());
pConn->Close();
}
}
bool C4Network2::CheckConn(const C4ClientCore &CCore, C4Network2IOConnection *pConn, C4Network2Client *pClient, const char *&szReply)
bool C4Network2::CheckConn(const C4ClientCore &CCore, C4Network2IOConnection *pConn, C4Network2Client *pClient, const char *szReply)
{
if(!pConn || !pClient) return false;
// already connected? (shouldn't happen really)
@ -1154,7 +1153,7 @@ bool C4Network2::CheckConn(const C4ClientCore &CCore, C4Network2IOConnection *pC
return true;
}
bool C4Network2::HostConnect(const C4ClientCore &CCore, C4Network2IOConnection *pConn, const char *&szReply)
bool C4Network2::HostConnect(const C4ClientCore &CCore, C4Network2IOConnection *pConn, const char *szReply)
{
if(!pConn) return false;
if(!CCore.isHost()) { szReply = "not host"; return false; }
@ -1166,7 +1165,7 @@ bool C4Network2::HostConnect(const C4ClientCore &CCore, C4Network2IOConnection *
return true;
}
bool C4Network2::Join(C4ClientCore &CCore, C4Network2IOConnection *pConn, const char *&szReply)
bool C4Network2::Join(C4ClientCore &CCore, C4Network2IOConnection *pConn, const char *szReply)
{
if(!pConn) return false;
// security

View File

@ -176,8 +176,7 @@ void C4Network2ClientListBox::ClientListItem::Update()
if (pPing)
{
int iWait = Game.Control.Network.ClientPerfStat(iClientID);
sprintf(OSTR, "%d ms", iWait);
pPing->SetText(OSTR);
pPing->SetText(FormatString("%d ms", iWait).getData());
pPing->SetColor(RGB(
BoundBy(255-Abs(iWait)*5, 0, 255),
BoundBy(255-iWait*5, 0, 255),

View File

@ -59,12 +59,13 @@ void C4Network2ResDlg::ListItem::Update(const C4Network2Res *pByRes)
iProgress = pByRes->getPresentPercent();
if (iProgress < 100)
{
sprintf(OSTR, "%d%%", iProgress);
StdStrBuf progress;
progress.Format("%d%%", iProgress);
if (pProgress)
pProgress->SetText(OSTR);
pProgress->SetText(progress.getData());
else
{
pProgress = new C4GUI::Label(OSTR, GetBounds().Wdt - IconLabelSpacing, 0, ARight);
pProgress = new C4GUI::Label(progress.getData(), GetBounds().Wdt - IconLabelSpacing, 0, ARight);
pProgress->SetToolTip(LoadResStr("IDS_NET_RESPROGRESS_DESC"));
AddElement(pProgress);
}
@ -115,8 +116,8 @@ void C4Network2ResDlg::ListItem::LocalSaveResource(bool fDoOverwrite)
if (!fDoOverwrite && ItemExists(szTarget))
{
// show a confirmation dlg, asking whether the ressource should be overwritten
sprintf(OSTR, LoadResStr("IDS_NET_RES_SAVE_OVERWRITE"), GetFilename(szTarget));
GetScreen()->ShowRemoveDlg(new C4GUI::ConfirmationDialog(OSTR, LoadResStr("IDS_NET_RES_SAVE"),
GetScreen()->ShowRemoveDlg(new C4GUI::ConfirmationDialog(
FormatString(LoadResStr("IDS_NET_RES_SAVE_OVERWRITE"), GetFilename(szTarget)).getData(), LoadResStr("IDS_NET_RES_SAVE"),
new C4GUI::CallbackHandler<C4Network2ResDlg::ListItem>(this, &C4Network2ResDlg::ListItem::OnButtonSaveConfirm), C4GUI::MessageDialog::btnYesNo));
return;
}
@ -124,8 +125,8 @@ void C4Network2ResDlg::ListItem::LocalSaveResource(bool fDoOverwrite)
GetScreen()->ShowMessage(strErrCopyFile.getData(), strErrCopyFile.getData(), C4GUI::Ico_Error);
else
{
sprintf(OSTR, LoadResStr("IDS_NET_RES_SAVED_DESC"), GetFilename(szTarget));
GetScreen()->ShowMessage(OSTR, LoadResStr("IDS_NET_RES_SAVED"), C4GUI::Ico_Save);
GetScreen()->ShowMessage(FormatString(LoadResStr("IDS_NET_RES_SAVED_DESC"), GetFilename(szTarget)).getData(),
LoadResStr("IDS_NET_RES_SAVED"), C4GUI::Ico_Save);
}
}

View File

@ -1009,8 +1009,7 @@ BOOL C4Object::ExecLife()
if(Info->Age != iNewAge && Info->Age)
{
// message
sprintf(OSTR,LoadResStr("IDS_OBJ_BIRTHDAY"),GetName (), Info->TotalPlayingTime / 3600 / 5);
GameMsgObject(OSTR,this);
GameMsgObject(FormatString(LoadResStr("IDS_OBJ_BIRTHDAY"),GetName (), Info->TotalPlayingTime / 3600 / 5).getData(),this);
StartSoundEffect("Trumpet",false,100,this);
}
@ -1621,8 +1620,7 @@ BOOL C4Object::ActivateEntrance(int32_t by_plr, C4Object *by_obj)
if (Hostile(by_plr,Base) && (Game.C4S.Game.Realism.BaseFunctionality & BASEFUNC_RejectEntrance))
{
if (ValidPlr(Owner))
{ sprintf(OSTR,LoadResStr("IDS_OBJ_HOSTILENOENTRANCE"),Game.Players.Get(Owner)->GetName());
GameMsgObject(OSTR,this); }
GameMsgObject(FormatString(LoadResStr("IDS_OBJ_HOSTILENOENTRANCE"),Game.Players.Get(Owner)->GetName()).getData(),this);
return FALSE;
}
// Try entrance activation
@ -1787,8 +1785,7 @@ BOOL C4Object::Push(FIXED txdir, FIXED dforce, BOOL fStraighten)
if (!Tick35) if (txdir) if (!Def->NoHorizontalMove)
if (ContactCheck(GetX(), GetY())) // Resets t_contact
{
sprintf(OSTR,LoadResStr("IDS_OBJ_STUCK"),GetName());
GameMsgObject(OSTR,this);
GameMsgObject(FormatString(LoadResStr("IDS_OBJ_STUCK"),GetName()).getData(),this);
Call(PSF_Stuck);
}
@ -1816,8 +1813,7 @@ BOOL C4Object::Lift(FIXED tydir, FIXED dforce)
if (tydir != -GravAccel)
if (ContactCheck(GetX(), GetY())) // Resets t_contact
{
sprintf(OSTR,LoadResStr("IDS_OBJ_STUCK"),GetName());
GameMsgObject(OSTR,this);
GameMsgObject(FormatString(LoadResStr("IDS_OBJ_STUCK"),GetName()).getData(),this);
Call(PSF_Stuck);
}
return TRUE;
@ -1949,8 +1945,8 @@ BOOL C4Object::ActivateMenu(int32_t iMenu, int32_t iMenuSelect,
fctSymbol.Create(C4SymbolSize,C4SymbolSize);
DrawMenuSymbol(C4MN_Construction,fctSymbol,-1,NULL);
// Init menu
sprintf(OSTR,LoadResStr("IDS_PLR_NOBKNOW"),pPlayer->GetName());
Menu->Init(fctSymbol,OSTR,this,C4MN_Extra_Components,0,iMenu);
Menu->Init(fctSymbol,FormatString(LoadResStr("IDS_PLR_NOBKNOW"),pPlayer->GetName()).getData(),
this,C4MN_Extra_Components,0,iMenu);
// Add player's structure build knowledge
for (cnt=0; pDef=C4Id2Def(pPlayer->Knowledge.GetID(Game.Defs,C4D_Structure,cnt,&iCount)); cnt++)
{
@ -2470,9 +2466,10 @@ void C4Object::Draw(C4TargetFacet &cgo, int32_t iByPlayer, DrawMode eDrawMode)
{
if (Action.Act>ActIdle)
{
sprintf(OSTR,"%s (%d)",Def->ActMap[Action.Act].Name,Action.Phase);
int32_t cmwdt,cmhgt; Game.GraphicsResource.FontRegular.GetTextExtent(OSTR,cmwdt,cmhgt,true);
Application.DDraw->TextOut(OSTR, Game.GraphicsResource.FontRegular, 1.0, cgo.Surface,cgo.X+cox-Shape.GetX(),cgo.Y+coy-cmhgt,InLiquid ? 0xfa0000FF : CStdDDraw::DEFAULT_MESSAGE_COLOR,ACenter);
StdStrBuf str;
str.Format("%s (%d)",Def->ActMap[Action.Act].Name,Action.Phase);
int32_t cmwdt,cmhgt; Game.GraphicsResource.FontRegular.GetTextExtent(str.getData(),cmwdt,cmhgt,true);
Application.DDraw->TextOut(str.getData(), Game.GraphicsResource.FontRegular, 1.0, cgo.Surface,cgo.X+cox-Shape.GetX(),cgo.Y+coy-cmhgt,InLiquid ? 0xfa0000FF : CStdDDraw::DEFAULT_MESSAGE_COLOR,ACenter);
}
}
// Debug Display ///////////////////////////////////////////////////////////////////////
@ -2903,11 +2900,11 @@ void C4Object::DrawCommands(C4Facet &cgoBottom, C4Facet &cgoSide, C4RegionList *
DWORD ocf = OCF_Construct;
if(Action.ComDir == COMD_Stop && iDFA == DFA_WALK && (tObj = Game.Objects.AtObject(GetX(), GetY(), ocf, this)))
{
sprintf(OSTR, LoadResStr("IDS_CON_BUILD"), tObj->GetName());
int32_t com = COM_Down_D;
if(Game.Players.Get(Controller)->PrefControlStyle) com = COM_Down;
tObj->DrawCommand(cgoBottom,C4FCT_Right,NULL,com,pRegions,Owner,OSTR,&ccgo);
tObj->DrawCommand(cgoBottom,C4FCT_Right,NULL,com,pRegions,Owner,
FormatString(LoadResStr("IDS_CON_BUILD"), tObj->GetName()).getData(),&ccgo);
tObj->Def->Draw(ccgo2 = ccgo.GetFraction(85, 85, C4FCT_Right, C4FCT_Top), FALSE, tObj->Color, tObj);
Game.GraphicsResource.fctBuild.Draw(ccgo2 = ccgo.GetFraction(85, 85, C4FCT_Left, C4FCT_Bottom), TRUE);
}
@ -2928,8 +2925,8 @@ void C4Object::DrawCommands(C4Facet &cgoBottom, C4Facet &cgoSide, C4RegionList *
|| (ComOrder(cnt) == COM_Down && !letgobydouble))
{
// Let Go
sprintf(OSTR,LoadResStr("IDS_CON_UNGRAB"), Action.Target->GetName());
Action.Target->DrawCommand(cgoBottom, C4FCT_Right, NULL, ComOrder(cnt), pRegions, Owner, OSTR, &ccgo);
Action.Target->DrawCommand(cgoBottom, C4FCT_Right, NULL, ComOrder(cnt), pRegions, Owner,
FormatString(LoadResStr("IDS_CON_UNGRAB"), Action.Target->GetName()).getData(), &ccgo);
Action.Target->Def->Draw(ccgo2 = ccgo.GetFraction(85, 85, C4FCT_Right, C4FCT_Top), FALSE, Action.Target->Color, Action.Target);
Game.GraphicsResource.fctHand.Draw(ccgo2 = ccgo.GetFraction(85, 85, C4FCT_Left, C4FCT_Bottom), TRUE, 6);
}
@ -2938,16 +2935,16 @@ void C4Object::DrawCommands(C4Facet &cgoBottom, C4Facet &cgoSide, C4RegionList *
// Put
if ((tObj = Contents.GetObject()) && (Action.Target->Def->GrabPutGet & C4D_Grab_Put))
{
sprintf(OSTR, LoadResStr("IDS_CON_PUT"), tObj->GetName(), Action.Target->GetName());
Action.Target->DrawCommand(cgoBottom, C4FCT_Right, NULL, COM_Throw, pRegions, Owner, OSTR, &ccgo);
Action.Target->DrawCommand(cgoBottom, C4FCT_Right, NULL, COM_Throw, pRegions, Owner,
FormatString(LoadResStr("IDS_CON_PUT"), tObj->GetName(), Action.Target->GetName()).getData(), &ccgo);
tObj->Def->Draw(ccgo2 = ccgo.GetFraction(85, 85, C4FCT_Right, C4FCT_Top), FALSE, tObj->Color, tObj);
Game.GraphicsResource.fctHand.Draw(ccgo2 = ccgo.GetFraction(85, 85, C4FCT_Left, C4FCT_Bottom), TRUE, 0);
}
// Get
else if (Action.Target->Contents.ListIDCount(C4D_Get) && (Action.Target->Def->GrabPutGet & C4D_Grab_Get))
{
sprintf(OSTR,LoadResStr("IDS_CON_GET"),Action.Target->GetName());
Action.Target->DrawCommand(cgoBottom,C4FCT_Right,NULL,COM_Throw,pRegions,Owner,OSTR, &ccgo);
Action.Target->DrawCommand(cgoBottom,C4FCT_Right,NULL,COM_Throw,pRegions,Owner,
FormatString(LoadResStr("IDS_CON_GET"),Action.Target->GetName()).getData(), &ccgo);
Action.Target->Def->Draw(ccgo2 = ccgo.GetFraction(85, 85, C4FCT_Right, C4FCT_Top), FALSE, Action.Target->Color, Action.Target);
Game.GraphicsResource.fctHand.Draw(ccgo2 = ccgo.GetFraction(85, 85, C4FCT_Left, C4FCT_Bottom), TRUE, 1);
}
@ -2970,9 +2967,8 @@ void C4Object::DrawCommands(C4Facet &cgoBottom, C4Facet &cgoSide, C4RegionList *
// Contained exit
if (!fContainedDownOverride)
{
SCopy(LoadResStr("IDS_CON_EXIT"),OSTR);
DrawCommand(cgoBottom,C4FCT_Right,NULL,COM_Down,pRegions,Owner,
OSTR,&ccgo);
LoadResStr("IDS_CON_EXIT"),&ccgo);
Game.GraphicsResource.fctExit.Draw(ccgo);
}
// Contained base commands
@ -2981,15 +2977,15 @@ void C4Object::DrawCommands(C4Facet &cgoBottom, C4Facet &cgoSide, C4RegionList *
// Sell
if (Game.C4S.Game.Realism.BaseFunctionality & BASEFUNC_Sell)
{
SCopy(LoadResStr("IDS_CON_SELL"),OSTR);
Contained->DrawCommand(cgoBottom,C4FCT_Right,NULL,COM_Dig,pRegions,Owner,OSTR,&ccgo);
Contained->DrawCommand(cgoBottom,C4FCT_Right,NULL,COM_Dig,pRegions,Owner,
LoadResStr("IDS_CON_SELL"),&ccgo);
DrawMenuSymbol(C4MN_Sell,ccgo,Contained->Base,Contained);
}
// Buy
if (Game.C4S.Game.Realism.BaseFunctionality & BASEFUNC_Buy)
{
SCopy(LoadResStr("IDS_CON_BUY"),OSTR);
Contained->DrawCommand(cgoBottom,C4FCT_Right,NULL,COM_Up,pRegions,Owner,OSTR,&ccgo);
Contained->DrawCommand(cgoBottom,C4FCT_Right,NULL,COM_Up,pRegions,Owner,
LoadResStr("IDS_CON_BUY"),&ccgo);
DrawMenuSymbol(C4MN_Buy,ccgo,Contained->Base,Contained);
}
}
@ -3001,16 +2997,16 @@ void C4Object::DrawCommands(C4Facet &cgoBottom, C4Facet &cgoSide, C4RegionList *
// carlo: Direct get ("Take2")
if (!fContainedRightOverride)
{
sprintf(OSTR,LoadResStr("IDS_CON_GET"),Contained->GetName());
Contained->DrawCommand(cgoBottom,C4FCT_Right,NULL,COM_Right,pRegions,Owner,OSTR,&ccgo);
Contained->DrawCommand(cgoBottom,C4FCT_Right,NULL,COM_Right,pRegions,Owner,
FormatString(LoadResStr("IDS_CON_GET"),Contained->GetName()).getData(),&ccgo);
Contained->Def->Draw(ccgo2 = ccgo.GetFraction(85, 85, C4FCT_Right, C4FCT_Top), FALSE, Contained->Color, Contained);
Game.GraphicsResource.fctHand.Draw(ccgo2 = ccgo.GetFraction(85, 85, C4FCT_Left, C4FCT_Bottom), TRUE, 1);
}
// carlo: Get ("Take")
if (!fContainedLeftOverride)
{
sprintf(OSTR,LoadResStr("IDS_CON_ACTIVATEFROM"),Contained->GetName());
Contained->DrawCommand(cgoBottom,C4FCT_Right,NULL,COM_Left,pRegions,Owner,OSTR,&ccgo);
Contained->DrawCommand(cgoBottom,C4FCT_Right,NULL,COM_Left,pRegions,Owner,
FormatString(LoadResStr("IDS_CON_ACTIVATEFROM"),Contained->GetName()).getData(),&ccgo);
Contained->Def->Draw(ccgo2 = ccgo.GetFraction(85, 85, C4FCT_Right, C4FCT_Top), FALSE, Contained->Color, Contained);
Game.GraphicsResource.fctHand.Draw(ccgo2 = ccgo.GetFraction(85, 85, C4FCT_Left, C4FCT_Bottom), TRUE, 0);
}
@ -3018,16 +3014,16 @@ void C4Object::DrawCommands(C4Facet &cgoBottom, C4Facet &cgoSide, C4RegionList *
if (tObj=Contents.GetObject())
{
// Put
sprintf(OSTR,LoadResStr("IDS_CON_PUT"),tObj->GetName(),Contained->GetName());
Contained->DrawCommand(cgoBottom,C4FCT_Right,NULL,COM_Throw,pRegions,Owner,OSTR,&ccgo);
Contained->DrawCommand(cgoBottom,C4FCT_Right,NULL,COM_Throw,pRegions,Owner,
FormatString(LoadResStr("IDS_CON_PUT"),tObj->GetName(),Contained->GetName()).getData(),&ccgo);
tObj->Def->Draw(ccgo2 = ccgo.GetFraction(85, 85, C4FCT_Right, C4FCT_Top), FALSE, tObj->Color, tObj);
Game.GraphicsResource.fctHand.Draw(ccgo2 = ccgo.GetFraction(85, 85, C4FCT_Left, C4FCT_Bottom), TRUE, 0);
}
else if (nContents)
{
// Get
sprintf(OSTR,LoadResStr("IDS_CON_ACTIVATEFROM"),Contained->GetName());
Contained->DrawCommand(cgoBottom,C4FCT_Right,NULL,COM_Throw,pRegions,Owner,OSTR,&ccgo);
Contained->DrawCommand(cgoBottom,C4FCT_Right,NULL,COM_Throw,pRegions,Owner,
FormatString(LoadResStr("IDS_CON_ACTIVATEFROM"),Contained->GetName()).getData(),&ccgo);
Contained->Def->Draw(ccgo2 = ccgo.GetFraction(85, 85, C4FCT_Right, C4FCT_Top), FALSE, Contained->Color, Contained);
Game.GraphicsResource.fctHand.Draw(ccgo2 = ccgo.GetFraction(85, 85, C4FCT_Left, C4FCT_Bottom), TRUE, 0);
}

View File

@ -363,8 +363,7 @@ BOOL ObjectComDig(C4Object *cObj) // by DFA_WALK
C4PhysicalInfo *phys=cObj->GetPhysical();
if (!phys->CanDig || !ObjectActionDig(cObj))
{
sprintf(OSTR,LoadResStr("IDS_OBJ_NODIG"),cObj->GetName());
GameMsgObject(OSTR,cObj);
GameMsgObject(FormatString(LoadResStr("IDS_OBJ_NODIG"),cObj->GetName()).getData(),cObj);
return FALSE;
}
return TRUE;
@ -395,8 +394,7 @@ BOOL ObjectComLineConstruction(C4Object *cObj)
// Check physical
if (!cObj->GetPhysical()->CanConstruct)
{
sprintf(OSTR,LoadResStr("IDS_OBJ_NOLINECONSTRUCT"),cObj->GetName());
GameMsgObject(OSTR,cObj); return FALSE;
GameMsgObject(FormatString(LoadResStr("IDS_OBJ_NOLINECONSTRUCT"),cObj->GetName()).getData(),cObj); return FALSE;
}
// - - - - - - - - - - - - - - - - - - Line pickup - - - - - - - - - - - - - - - - -
@ -416,8 +414,7 @@ BOOL ObjectComLineConstruction(C4Object *cObj)
|| (cline->Action.Target2 && (cline->Action.Target2->Def->id==C4ID_Linekit)) )
{
StartSoundEffect("Error",false,100,cObj);
sprintf(OSTR,LoadResStr("IDS_OBJ_NODOUBLEKIT"),cline->GetName());
GameMsgObject(OSTR,cObj); return FALSE;
GameMsgObject(FormatString(LoadResStr("IDS_OBJ_NODOUBLEKIT"),cline->GetName()).getData(),cObj); return FALSE;
}
// Create new linekit
if (!(linekit=Game.CreateObject(C4ID_Linekit,cObj,cline->Owner))) return FALSE;
@ -433,8 +430,7 @@ BOOL ObjectComLineConstruction(C4Object *cObj)
if (cline->Action.Target==tstruct) cline->Action.Target=linekit;
if (cline->Action.Target2==tstruct) cline->Action.Target2=linekit;
// Message
sprintf(OSTR,LoadResStr("IDS_OBJ_DISCONNECT"),cline->GetName(),tstruct->GetName());
GameMsgObject(OSTR,tstruct);
GameMsgObject(FormatString(LoadResStr("IDS_OBJ_DISCONNECT"),cline->GetName(),tstruct->GetName()).getData(),tstruct);
return TRUE;
}
@ -452,8 +448,7 @@ BOOL ObjectComLineConstruction(C4Object *cObj)
{
// No connect
StartSoundEffect("Error",false,100,cObj);
sprintf(OSTR,LoadResStr("IDS_OBJ_NOCONNECT"));
GameMsgObject(OSTR,cObj); return FALSE;
GameMsgObject(FormatString(LoadResStr("IDS_OBJ_NOCONNECT")).getData(),cObj); return FALSE;
}
// Check short circuit -> removal
@ -461,8 +456,7 @@ BOOL ObjectComLineConstruction(C4Object *cObj)
|| (cline->Action.Target2==tstruct))
{
StartSoundEffect("Connect",false,100,cObj);
sprintf(OSTR,LoadResStr("IDS_OBJ_LINEREMOVAL"),cline->GetName());
GameMsgObject(OSTR,tstruct);
GameMsgObject(FormatString(LoadResStr("IDS_OBJ_LINEREMOVAL"),cline->GetName()).getData(),tstruct);
cline->AssignRemoval();
return TRUE;
}
@ -484,8 +478,8 @@ BOOL ObjectComLineConstruction(C4Object *cObj)
if (!connect_okay)
{
StartSoundEffect("Error",false,100,cObj);
sprintf(OSTR,LoadResStr("IDS_OBJ_NOCONNECTTYPE"),cline->GetName(),tstruct->GetName());
GameMsgObject(OSTR,tstruct); return FALSE;
GameMsgObject(FormatString(LoadResStr("IDS_OBJ_NOCONNECTTYPE"),cline->GetName(),tstruct->GetName()).getData(),tstruct);
return FALSE;
}
// Connect line to structure
@ -495,8 +489,7 @@ BOOL ObjectComLineConstruction(C4Object *cObj)
linekit->Exit();
linekit->AssignRemoval();
sprintf(OSTR,LoadResStr("IDS_OBJ_CONNECT"),cline->GetName(),tstruct->GetName());
GameMsgObject(OSTR,tstruct);
GameMsgObject(FormatString(LoadResStr("IDS_OBJ_CONNECT"),cline->GetName(),tstruct->GetName()).getData(),tstruct);
return TRUE;
}
@ -509,8 +502,7 @@ BOOL ObjectComLineConstruction(C4Object *cObj)
if (!tstruct || !(ocf & OCF_LineConstruct))
{
StartSoundEffect("Error",false,100,cObj);
sprintf(OSTR,LoadResStr("IDS_OBJ_NONEWLINE"));
GameMsgObject(OSTR,cObj); return FALSE;
GameMsgObject(FormatString(LoadResStr("IDS_OBJ_NONEWLINE")).getData(),cObj); return FALSE;
}
// Determine new line type
@ -533,8 +525,7 @@ BOOL ObjectComLineConstruction(C4Object *cObj)
if (linetype==C4ID_None)
{
StartSoundEffect("Error",false,100,cObj);
sprintf(OSTR,LoadResStr("IDS_OBJ_NONEWLINE"));
GameMsgObject(OSTR,cObj); return FALSE;
GameMsgObject(FormatString(LoadResStr("IDS_OBJ_NONEWLINE")).getData(),cObj); return FALSE;
}
// Create new line
@ -542,8 +533,7 @@ BOOL ObjectComLineConstruction(C4Object *cObj)
tstruct,linekit);
if (!newline) return FALSE;
StartSoundEffect("Connect",false,100,cObj);
sprintf(OSTR,LoadResStr("IDS_OBJ_NEWLINE"),newline->GetName());
GameMsgObject(OSTR,tstruct);
GameMsgObject(FormatString(LoadResStr("IDS_OBJ_NEWLINE"),newline->GetName()).getData(),tstruct);
return TRUE;
}
@ -697,8 +687,7 @@ BOOL ObjectComChop(C4Object *cObj, C4Object *pTarget)
if (!pTarget) return FALSE;
if (!cObj->GetPhysical()->CanChop)
{
sprintf(OSTR,LoadResStr("IDS_OBJ_NOCHOP"),cObj->GetName());
GameMsgObject(OSTR,cObj);
GameMsgObject(FormatString(LoadResStr("IDS_OBJ_NOCHOP"),cObj->GetName()).getData(),cObj);
return FALSE;
}
if (cObj->GetProcedure()!=DFA_WALK) return FALSE;
@ -965,15 +954,15 @@ BOOL SellFromBase(int32_t iPlr, C4Object *pBaseObj, C4ID id, C4Object *pSellObj)
if (Game.Players.Get(pBaseObj->Base)->Eliminated)
{
StartSoundEffect("Error",false,100,pBaseObj);
sprintf(OSTR,LoadResStr("IDS_PLR_ELIMINATED"),Game.Players.Get(pBaseObj->Base)->GetName());
GameMsgPlayer(OSTR,iPlr); return FALSE;
GameMsgPlayer(FormatString(LoadResStr("IDS_PLR_ELIMINATED"),Game.Players.Get(pBaseObj->Base)->GetName()).getData(),iPlr);
return FALSE;
}
// Base owner hostile
if (Hostile(iPlr,pBaseObj->Base))
{
StartSoundEffect("Error",false,100,pBaseObj);
sprintf(OSTR,LoadResStr("IDS_PLR_HOSTILE"),Game.Players.Get(pBaseObj->Base)->GetName());
GameMsgPlayer(OSTR,iPlr); return FALSE;
GameMsgPlayer(FormatString(LoadResStr("IDS_PLR_HOSTILE"),Game.Players.Get(pBaseObj->Base)->GetName()).getData(),iPlr);
return FALSE;
}
// check validity of sell object, if specified
if (pThing = pSellObj)
@ -1000,8 +989,7 @@ BOOL Buy2Base(int32_t iPlr, C4Object *pBase, C4ID id, BOOL fShowErrors)
{
if (!fShowErrors) return FALSE;
StartSoundEffect("Error",false,100,pBase);
sprintf(OSTR,LoadResStr("IDS_PLR_HOSTILE"),Game.Players.Get(pBase->Base)->GetName());
GameMsgPlayer(OSTR,iPlr); return FALSE;
GameMsgPlayer(FormatString(LoadResStr("IDS_PLR_HOSTILE"),Game.Players.Get(pBase->Base)->GetName()).getData(),iPlr); return FALSE;
}
// buy
if (!(pThing=Game.Players.Get(pBase->Base)->Buy(id, fShowErrors, iPlr, pBase))) return FALSE;

View File

@ -351,9 +351,10 @@ void C4ObjectInfo::Draw(C4Facet &cgo, BOOL fShowPortrait, BOOL fCaptain, C4Objec
pRankSys->DrawRankSymbol(NULL, Rank, pRankRes, iRankCnt, false, iX, &cgo);
iX+=Game.GraphicsResource.fctRank.Wdt;
// Rank & Name
if (Rank>0) sprintf(OSTR,"%s|%s",sRankName.getData(),pOfObj->GetName ());
else sprintf(OSTR,"%s",pOfObj->GetName ());
Application.DDraw->TextOut(OSTR, Game.GraphicsResource.FontRegular, 1.0, cgo.Surface,cgo.X+iX,cgo.Y,CStdDDraw::DEFAULT_MESSAGE_COLOR,ALeft);
StdStrBuf name;
if (Rank>0) name.Format("%s|%s",sRankName.getData(),pOfObj->GetName ());
else name.Format("%s",pOfObj->GetName ());
Application.DDraw->TextOut(name.getData(), Game.GraphicsResource.FontRegular, 1.0, cgo.Surface,cgo.X+iX,cgo.Y,CStdDDraw::DEFAULT_MESSAGE_COLOR,ALeft);
#endif // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
}

View File

@ -540,8 +540,8 @@ C4GUI::ContextMenu *C4PlayerInfoListBox::PlayerListItem::OnContextTakeOver(C4GUI
if (!pInfo->HasJoinIssued())
if (!pInfo->GetAssociatedSavegamePlayerID())
{
sprintf(OSTR, LoadResStr("IDS_MSG_USINGPLR"), pInfo->GetName());
pMenu->AddItem(OSTR, LoadResStr("IDS_MSG_USINGPLR_DESC"), C4GUI::Ico_Player,
pMenu->AddItem(FormatString(LoadResStr("IDS_MSG_USINGPLR"), pInfo->GetName()).getData(),
LoadResStr("IDS_MSG_USINGPLR_DESC"), C4GUI::Ico_Player,
new C4GUI::CBMenuHandlerEx<PlayerListItem, int32_t>(this, &PlayerListItem::OnCtxTakeOver, pInfo->GetID()));
}
}
@ -750,8 +750,7 @@ C4PlayerInfoListBox::ClientListItem::ClientListItem(C4PlayerInfoListBox *pForLis
AddElement(pStatusIcon); AddElement(pNameLabel);
if (btnAddPlayer) AddElement(btnAddPlayer);
// tooltip (same for all components for now. seperate tooltip for status icon later?)
sprintf(OSTR, "Client %s (%s)", rClientInfo.getName(), rClientInfo.getNick());
SetToolTip(OSTR);
SetToolTip(FormatString("Client %s (%s)", rClientInfo.getName(), rClientInfo.getNick()).getData());
// insert into listbox at correct order
// (will eventually get resized horizontally and moved)
pForListBox->InsertElement(this, pInsertBefore);
@ -777,17 +776,18 @@ void C4PlayerInfoListBox::ClientListItem::SetPing(int32_t iToPing)
return;
}
// get ping as text
sprintf(OSTR, "%d ms", iToPing);
StdStrBuf ping;
ping.Format("%d ms", iToPing);
// create ping label if necessary
if (!pPingLabel)
{
pPingLabel = new C4GUI::Label(OSTR, GetBounds().Wdt, 0, ARight, C4GUI_MessageFontClr);
pPingLabel = new C4GUI::Label(ping.getData(), GetBounds().Wdt, 0, ARight, C4GUI_MessageFontClr);
pPingLabel->SetToolTip(LoadResStr("IDS_DLGTIP_PING"));
AddElement(pPingLabel);
}
else
// or just set updated text
pPingLabel->SetText(OSTR);
pPingLabel->SetText(ping.getData());
}
void C4PlayerInfoListBox::ClientListItem::UpdateInfo()

View File

@ -351,14 +351,12 @@ void C4PropertyDlg::UpdateInputCtrl(C4Object *pObj)
for (C4AulFunc *pFn = Game.ScriptEngine.GetFirstFunc(); pFn; pFn = Game.ScriptEngine.GetNextFunc(pFn))
if (pFn->GetPublic())
{
SCopy(pFn->Name, OSTR);
#ifdef _WIN32
SAppend("()",OSTR);
SendMessage(hCombo,CB_ADDSTRING,0,(LPARAM)OSTR);
SendMessage(hCombo,CB_ADDSTRING,0,(LPARAM)pFn->Name);
#else
#ifdef WITH_DEVELOPER_MODE
gtk_list_store_append(store, &iter);
gtk_list_store_set(store, &iter, 0, OSTR, -1);
gtk_list_store_set(store, &iter, 0, pFn->Name, -1);
#endif
#endif
}
@ -379,14 +377,12 @@ void C4PropertyDlg::UpdateInputCtrl(C4Object *pObj)
if (!fDivider) { SendMessage(hCombo,CB_INSERTSTRING,0,(LPARAM)"----------"); fDivider=TRUE; }
#endif
// Add function
SCopy(pRef->Name,OSTR);
#ifdef _WIN32
SAppend("()",OSTR);
SendMessage(hCombo,CB_INSERTSTRING,0,(LPARAM)OSTR);
SendMessage(hCombo,CB_INSERTSTRING,0,(LPARAM)pRef->Name);
#else
#ifdef WITH_DEVELOPER_MODE
gtk_list_store_append(store, &iter);
gtk_list_store_set(store, &iter, 0, OSTR, -1);
gtk_list_store_set(store, &iter, 0, pRef->Name, -1);
#endif
#endif
}

View File

@ -5951,8 +5951,7 @@ static bool FnSetPreSend(C4AulContext *cthr, long iToVal, C4String *pNewName)
if (!szClient || !*szClient || WildcardMatch(szClient, Game.Clients.getLocalName()))
{
Game.Control.Network.setTargetFPS(iToVal);
sprintf(OSTR, "TargetFPS: %ld", iToVal);
Game.GraphicsSystem.FlashMessage(OSTR);
Game.GraphicsSystem.FlashMessage(FormatString("TargetFPS: %ld", iToVal).getData());
}
return TRUE;
}

View File

@ -93,16 +93,17 @@ BOOL C4Sky::Init(bool fSavegame)
// Scan list sections
SReplaceChar(Game.C4S.Landscape.SkyDef,',',';'); // modifying the C4S here...!
skylistn=SCharCount(';',Game.C4S.Landscape.SkyDef)+1;
SCopySegment(Game.C4S.Landscape.SkyDef,SeededRandom(Game.RandomSeed,skylistn),OSTR,';');
SClearFrontBack(OSTR);
char str[402];
SCopySegment(Game.C4S.Landscape.SkyDef,SeededRandom(Game.RandomSeed,skylistn),str,';');
SClearFrontBack(str);
// Sky tile specified, try load
if (OSTR[0] && !SEqual(OSTR,"Default"))
if (*str && !SEqual(str,"Default"))
{
// Check for sky tile in scenario file
loaded = !!Surface->LoadAny(Game.ScenarioFile,OSTR,true,true);
loaded = !!Surface->LoadAny(Game.ScenarioFile,str,true,true);
if (!loaded)
{
loaded = !!Surface->LoadAny(Game.GraphicsResource.Files, OSTR, true);
loaded = !!Surface->LoadAny(Game.GraphicsResource.Files, str, true);
}
}
}

View File

@ -194,10 +194,13 @@ BOOL CALLBACK ToolsDlgProc(HWND hDlg, UINT Msg, WPARAM wParam, LPARAM lParam)
switch (HIWORD(wParam))
{
case CBN_SELCHANGE:
{
char str[100];
int32_t cursel = SendDlgItemMessage(hDlg,IDC_COMBOMATERIAL,CB_GETCURSEL,0,0);
SendDlgItemMessage(hDlg,IDC_COMBOMATERIAL,CB_GETLBTEXT,cursel,(LPARAM)OSTR);
Console.ToolsDlg.SetMaterial(OSTR);
SendDlgItemMessage(hDlg,IDC_COMBOMATERIAL,CB_GETLBTEXT,cursel,(LPARAM)str);
Console.ToolsDlg.SetMaterial(str);
break;
}
}
return TRUE;
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
@ -205,10 +208,13 @@ BOOL CALLBACK ToolsDlgProc(HWND hDlg, UINT Msg, WPARAM wParam, LPARAM lParam)
switch (HIWORD(wParam))
{
case CBN_SELCHANGE:
{
char str[100];
int32_t cursel = SendDlgItemMessage(hDlg,IDC_COMBOTEXTURE,CB_GETCURSEL,0,0);
SendDlgItemMessage(hDlg,IDC_COMBOTEXTURE,CB_GETLBTEXT,cursel,(LPARAM)OSTR);
Console.ToolsDlg.SetTexture(OSTR);
SendDlgItemMessage(hDlg,IDC_COMBOTEXTURE,CB_GETLBTEXT,cursel,(LPARAM)str);
Console.ToolsDlg.SetTexture(str);
break;
}
}
return TRUE;
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -

View File

@ -201,9 +201,10 @@ void C4Video::Draw(C4TargetFacet &cgo)
X+cgo.X+Width-1,Y+cgo.Y+Height-1,
Recording ? CRed : CWhite);
// Draw status
if (Recording) sprintf(OSTR,"%dx%d Frame %d",Width,Height,AviFrame);
else sprintf(OSTR,"%dx%d",Width,Height);
Application.DDraw->TextOut(OSTR, Game.GraphicsResource.FontRegular, 1.0,cgo.Surface,cgo.X+X+4,cgo.Y+Y+3,Recording ? 0xfaFF0000 : 0xfaFFFFFF);
StdStrBuf str;
if (Recording) str.Format("%dx%d Frame %d",Width,Height,AviFrame);
else str.Format("%dx%d",Width,Height);
Application.DDraw->TextOut(str.getData(), Game.GraphicsResource.FontRegular, 1.0,cgo.Surface,cgo.X+X+4,cgo.Y+Y+3,Recording ? 0xfaFF0000 : 0xfaFFFFFF);
}
bool C4Video::AdjustPosition()

View File

@ -107,8 +107,7 @@ LRESULT APIENTRY ViewportWinProc(HWND hwnd, UINT uMsg, WPARAM wParam, LPARAM lPa
break;
//----------------------------------------------------------------------------------------------------------------------------------
case WM_DESTROY:
sprintf(OSTR,"Viewport%i",cvp->Player+1);
StoreWindowPosition(hwnd, OSTR, Config.GetSubkeyPath("Console"));
StoreWindowPosition(hwnd, FormatString("Viewport%i",cvp->Player+1).getData(), Config.GetSubkeyPath("Console"));
break;
//----------------------------------------------------------------------------------------------------------------------------------
case WM_CLOSE:
@ -1387,8 +1386,7 @@ BOOL C4Viewport::Init(CStdWindow * pParent, CStdApp * pApp, int32_t iPlayer)
if (!pWindow->Init(pApp, (Player==NO_OWNER) ? LoadResStr("IDS_CNS_VIEWPORT") : Game.Players.Get(Player)->GetName(), pParent, false))
return FALSE;
// Position and size
sprintf(OSTR, "Viewport%i", Player+1);
pWindow->RestorePosition(OSTR, Config.GetSubkeyPath("Console"));
pWindow->RestorePosition(FormatString("Viewport%i", Player+1).getData(), Config.GetSubkeyPath("Console"));
//UpdateWindow(hWnd);
// Updates
UpdateOutputSize();

View File

@ -807,15 +807,18 @@ int CStdFont::BreakMessage(const char *szMsg, int iWdt, char *szOut, int iMaxOut
// add chars to output
while (szLastPos != szPos)
{
*szOut++ = *szLastPos++;
if (!--iMaxOutLen)
if (szOut)
*szOut++ = *szLastPos++;
else
++szLastPos;
if (szOut && !--iMaxOutLen)
{
// buffer end: cut and terminate
*szOut = '\0';
break;
}
}
if (!iMaxOutLen) break;
if (szOut && !iMaxOutLen) break;
// add to line; always add one char at minimum
if ((iX+=iCharWdt) <= iWdt || fIsFirstLineChar)
{
@ -853,13 +856,16 @@ int CStdFont::BreakMessage(const char *szMsg, int iWdt, char *szOut, int iMaxOut
else
{
// otherwise, insert line break
if (!--iMaxOutLen)
if (szOut && !--iMaxOutLen)
// buffer is full
break;
char *szOut2 = szOut;
while (--szOut2 >= szLastBreakOut)
szOut2[1] = *szOut2;
szOut2[1] = '\n';
if (szOut)
{
char *szOut2 = szOut;
while (--szOut2 >= szLastBreakOut)
szOut2[1] = *szOut2;
szOut2[1] = '\n';
}
}
// calc next line usage
iX -= iXBreak;
@ -876,13 +882,14 @@ int CStdFont::BreakMessage(const char *szMsg, int iWdt, char *szOut, int iMaxOut
fIsFirstLineChar = true;
}
// transfer final data to buffer - markup and terminator
while (*szOut++ = *szLastPos++)
if (!--iMaxOutLen)
{
// buffer end: cut and terminate
*szOut = '\0';
break;
}
if (szOut)
while (*szOut++ = *szLastPos++)
if (!--iMaxOutLen)
{
// buffer end: cut and terminate
*szOut = '\0';
break;
}
// return text height
return iHgt;
}