In stats-only mode:
- Don't load all sprites
- Don't use sdl_ttf
- Don't load binds
--- a/hedgewars/hwengine.pas Thu Feb 13 23:53:47 2014 +0400
+++ b/hedgewars/hwengine.pas Fri Feb 14 13:48:14 2014 +0400
@@ -353,9 +353,12 @@
{$ENDIF}
SDL_ShowCursor(0);
- WriteToConsole('Init SDL_ttf... ');
- SDLTry(TTF_Init() <> -1, true);
- WriteLnToConsole(msgOK);
+ if not cOnlyStats then
+ begin
+ WriteToConsole('Init SDL_ttf... ');
+ SDLTry(TTF_Init() <> -1, true);
+ WriteLnToConsole(msgOK);
+ end;
{$IFDEF USE_VIDEO_RECORDING}
if GameType = gmtRecord then
--- a/hedgewars/uInputHandler.pas Thu Feb 13 23:53:47 2014 +0400
+++ b/hedgewars/uInputHandler.pas Fri Feb 14 13:48:14 2014 +0400
@@ -469,6 +469,8 @@
p, l: shortstring;
b: byte;
begin
+ if cOnlyStats then exit;
+
AddFileLog('[BINDS] Loading binds from: ' + s);
l:= '';
--- a/hedgewars/uRenderUtils.pas Thu Feb 13 23:53:47 2014 +0400
+++ b/hedgewars/uRenderUtils.pas Fri Feb 14 13:48:14 2014 +0400
@@ -277,24 +277,31 @@
var w, h: LongInt;
finalSurface: PSDL_Surface;
begin
- if length(s) = 0 then s:= _S' ';
- font:= CheckCJKFont(s, font);
- w:= 0; h:= 0; // avoid compiler hints
- TTF_SizeUTF8(Fontz[font].Handle, PChar(s), @w, @h);
- if (maxLength <> 0) and (w > maxLength) then w := maxLength;
-
- finalSurface:= SDL_CreateRGBSurface(SDL_SWSURFACE, w + cFontBorder * 2 + 4, h + cFontBorder * 2,
- 32, RMask, GMask, BMask, AMask);
+ if cOnlyStats then
+ begin
+ RenderStringTexLim:= nil;
+ end
+ else
+ begin
+ if length(s) = 0 then s:= _S' ';
+ font:= CheckCJKFont(s, font);
+ w:= 0; h:= 0; // avoid compiler hints
+ TTF_SizeUTF8(Fontz[font].Handle, PChar(s), @w, @h);
+ if (maxLength <> 0) and (w > maxLength) then w := maxLength;
- TryDo(finalSurface <> nil, 'RenderString: fail to create surface', true);
+ finalSurface:= SDL_CreateRGBSurface(SDL_SWSURFACE, w + cFontBorder * 2 + 4, h + cFontBorder * 2,
+ 32, RMask, GMask, BMask, AMask);
- WriteInRoundRect(finalSurface, 0, 0, Color, font, s, maxLength);
+ TryDo(finalSurface <> nil, 'RenderString: fail to create surface', true);
+
+ WriteInRoundRect(finalSurface, 0, 0, Color, font, s, maxLength);
- TryDo(SDL_SetColorKey(finalSurface, SDL_SRCCOLORKEY, 0) = 0, errmsgTransparentSet, true);
+ TryDo(SDL_SetColorKey(finalSurface, SDL_SRCCOLORKEY, 0) = 0, errmsgTransparentSet, true);
- RenderStringTexLim:= Surface2Tex(finalSurface, false);
+ RenderStringTexLim:= Surface2Tex(finalSurface, false);
- SDL_FreeSurface(finalSurface);
+ SDL_FreeSurface(finalSurface);
+ end;
end;
@@ -308,22 +315,24 @@
substr: shortstring;
edge, corner, tail: TSPrite;
begin
- case SpeechType of
+ if cOnlyStats then exit(nil);
+
+ case SpeechType of
1: begin;
- edge:= sprSpeechEdge;
- corner:= sprSpeechCorner;
- tail:= sprSpeechTail;
- end;
+ edge:= sprSpeechEdge;
+ corner:= sprSpeechCorner;
+ tail:= sprSpeechTail;
+ end;
2: begin;
- edge:= sprThoughtEdge;
- corner:= sprThoughtCorner;
- tail:= sprThoughtTail;
- end;
+ edge:= sprThoughtEdge;
+ corner:= sprThoughtCorner;
+ tail:= sprThoughtTail;
+ end;
3: begin;
- edge:= sprShoutEdge;
- corner:= sprShoutCorner;
- tail:= sprShoutTail;
- end;
+ edge:= sprShoutEdge;
+ corner:= sprShoutCorner;
+ tail:= sprShoutTail;
+ end;
end;
edgeHeight:= SpritesData[edge].Height;
edgeWidth:= SpritesData[edge].Width;
--- a/hedgewars/uStore.pas Thu Feb 13 23:53:47 2014 +0400
+++ b/hedgewars/uStore.pas Fri Feb 14 13:48:14 2014 +0400
@@ -171,7 +171,7 @@
foundBot: boolean;
year, month, md : word;
begin
- if cOnlyStats then exit;
+if cOnlyStats then exit;
r.x:= 0;
r.y:= 0;
drY:= - 4;
@@ -343,7 +343,7 @@
begin
AddFileLog('StoreLoad()');
-if not reload then
+if (not reload) and (not cOnlyStats) then
for fi:= Low(THWFont) to High(THWFont) do
with Fontz[fi] do
begin
@@ -355,8 +355,12 @@
WriteLnToConsole(msgOK)
end;
-MakeCrossHairs;
-LoadGraves;
+if not cOnlyStats then
+ begin
+ MakeCrossHairs;
+ LoadGraves;
+ end;
+
if not reload then
AddProgress;
@@ -364,11 +368,13 @@
with SpritesData[ii] do
// FIXME - add a sprite attribute to match on rq flags?
if (((cReducedQuality and (rqNoBackground or rqLowRes)) = 0) or // why rqLowRes?
- (not (ii in [sprSky, sprSkyL, sprSkyR, sprHorizont, sprHorizontL, sprHorizontR]))) and
- (((cReducedQuality and rqPlainSplash) = 0) or ((not (ii in [sprSplash, sprDroplet, sprSDSplash, sprSDDroplet])))) and
- (((cReducedQuality and rqKillFlakes) = 0) or cSnow or ((not (ii in [sprFlake, sprSDFlake])))) and
- ((cCloudsNumber > 0) or (ii <> sprCloud)) and
- ((vobCount > 0) or (ii <> sprFlake)) then
+ (not (ii in [sprSky, sprSkyL, sprSkyR, sprHorizont, sprHorizontL, sprHorizontR])))
+ and (((cReducedQuality and rqPlainSplash) = 0) or ((not (ii in [sprSplash, sprDroplet, sprSDSplash, sprSDDroplet]))))
+ and (((cReducedQuality and rqKillFlakes) = 0) or cSnow or ((not (ii in [sprFlake, sprSDFlake]))))
+ and ((cCloudsNumber > 0) or (ii <> sprCloud))
+ and ((vobCount > 0) or (ii <> sprFlake))
+ and (savesurf or (not cOnlyStats)) // in stats-only only load those which are needed later
+ then
begin
if reload then
tmpsurf:= Surface
@@ -426,53 +432,56 @@
Surface:= nil
end;
-WriteNames(fnt16);
+if not cOnlyStats then
+ begin
+ WriteNames(fnt16);
-if not reload then
- AddProgress;
+ if not reload then
+ AddProgress;
+
+ tmpsurf:= LoadDataImage(ptGraphics, cHHFileName, ifAlpha or ifCritical or ifTransparent);
-tmpsurf:= LoadDataImage(ptGraphics, cHHFileName, ifAlpha or ifCritical or ifTransparent);
+ HHTexture:= Surface2Tex(tmpsurf, false);
+ SDL_FreeSurface(tmpsurf);
+
+ InitHealth;
-HHTexture:= Surface2Tex(tmpsurf, false);
-SDL_FreeSurface(tmpsurf);
-
-InitHealth;
+ PauseTexture:= RenderStringTex(trmsg[sidPaused], cYellowColor, fntBig);
+ AFKTexture:= RenderStringTex(trmsg[sidAFK], cYellowColor, fntBig);
+ ConfirmTexture:= RenderStringTex(trmsg[sidConfirm], cYellowColor, fntBig);
+ SyncTexture:= RenderStringTex(trmsg[sidSync], cYellowColor, fntBig);
-PauseTexture:= RenderStringTex(trmsg[sidPaused], cYellowColor, fntBig);
-AFKTexture:= RenderStringTex(trmsg[sidAFK], cYellowColor, fntBig);
-ConfirmTexture:= RenderStringTex(trmsg[sidConfirm], cYellowColor, fntBig);
-SyncTexture:= RenderStringTex(trmsg[sidSync], cYellowColor, fntBig);
-
-if not reload then
- AddProgress;
+ if not reload then
+ AddProgress;
-// name of weapons in ammo menu
-for ai:= Low(TAmmoType) to High(TAmmoType) do
- with Ammoz[ai] do
+ // name of weapons in ammo menu
+ for ai:= Low(TAmmoType) to High(TAmmoType) do
+ with Ammoz[ai] do
+ begin
+ TryDo(length(trAmmo[NameId]) > 0,'No default text/translation found for ammo type #' + intToStr(ord(ai)) + '!',true);
+ tmpsurf:= TTF_RenderUTF8_Blended(Fontz[CheckCJKFont(trAmmo[NameId],fnt16)].Handle, PChar(trAmmo[NameId]), cWhiteColorChannels);
+ TryDo(tmpsurf <> nil,'Name-texture creation for ammo type #' + intToStr(ord(ai)) + ' failed!',true);
+ tmpsurf:= doSurfaceConversion(tmpsurf);
+ FreeTexture(NameTex);
+ NameTex:= Surface2Tex(tmpsurf, false);
+ SDL_FreeSurface(tmpsurf)
+ end;
+
+ // number of weapons in ammo menu
+ for i:= Low(CountTexz) to High(CountTexz) do
begin
- TryDo(length(trAmmo[NameId]) > 0,'No default text/translation found for ammo type #' + intToStr(ord(ai)) + '!',true);
- tmpsurf:= TTF_RenderUTF8_Blended(Fontz[CheckCJKFont(trAmmo[NameId],fnt16)].Handle, PChar(trAmmo[NameId]), cWhiteColorChannels);
- TryDo(tmpsurf <> nil,'Name-texture creation for ammo type #' + intToStr(ord(ai)) + ' failed!',true);
+ tmpsurf:= TTF_RenderUTF8_Blended(Fontz[fnt16].Handle, Str2PChar(IntToStr(i) + 'x'), cWhiteColorChannels);
tmpsurf:= doSurfaceConversion(tmpsurf);
- FreeTexture(NameTex);
- NameTex:= Surface2Tex(tmpsurf, false);
+ FreeTexture(CountTexz[i]);
+ CountTexz[i]:= Surface2Tex(tmpsurf, false);
SDL_FreeSurface(tmpsurf)
end;
-// number of weapons in ammo menu
-for i:= Low(CountTexz) to High(CountTexz) do
- begin
- tmpsurf:= TTF_RenderUTF8_Blended(Fontz[fnt16].Handle, Str2PChar(IntToStr(i) + 'x'), cWhiteColorChannels);
- tmpsurf:= doSurfaceConversion(tmpsurf);
- FreeTexture(CountTexz[i]);
- CountTexz[i]:= Surface2Tex(tmpsurf, false);
- SDL_FreeSurface(tmpsurf)
+ if not reload then
+ AddProgress;
end;
-if not reload then
- AddProgress;
IMG_Quit();
-
end;
{$IF DEFINED(USE_S3D_RENDERING) OR DEFINED(USE_VIDEO_RECORDING)}
--- a/hedgewars/uWorld.pas Thu Feb 13 23:53:47 2014 +0400
+++ b/hedgewars/uWorld.pas Fri Feb 14 13:48:14 2014 +0400
@@ -429,6 +429,8 @@
AMRect: TSDL_Rect;
{$IFDEF USE_AM_NUMCOLUMN}tmpsurf: PSDL_Surface;{$ENDIF}
begin
+ if cOnlyStats then exit(false);
+
SlotsNum:= 0;
for i:= 0 to cMaxSlotIndex do
if((i = 0) and (Ammo^[i,1].Count > 0)) or ((i <> 0) and (Ammo^[i,0].Count > 0)) then
@@ -1971,6 +1973,8 @@
procedure ShowMission(caption, subcaption, text: ansistring; icon, time : LongInt);
var r: TSDL_Rect;
begin
+if cOnlyStats then exit;
+
r.w:= 32;
r.h:= 32;