--- a/hedgewars/SDLh.pas Sun Aug 14 17:49:12 2011 -0400
+++ b/hedgewars/SDLh.pas Mon Aug 15 00:23:32 2011 +0200
@@ -833,8 +833,10 @@
function SDL_JoystickGetButton(joy: PSDL_Joystick; button: LongInt): Byte; cdecl; external SDLLibName;
procedure SDL_JoystickClose(joy: PSDL_Joystick); cdecl; external SDLLibName;
+{$IFDEF WIN32}
function SDL_putenv(const text: PChar): LongInt; cdecl; external SDLLibName;
function SDL_getenv(const text: PChar): PChar; cdecl; external SDLLibName;
+{$ENDIF}
{* Compatibility between SDL-1.2 and SDL-1.3 *}
procedure SDL_WarpMouse(x, y: Word); {$IFNDEF SDL13}cdecl; external SDLLibName;{$ENDIF}
--- a/hedgewars/hwengine.pas Sun Aug 14 17:49:12 2011 -0400
+++ b/hedgewars/hwengine.pas Mon Aug 15 00:23:32 2011 +0200
@@ -124,7 +124,6 @@
begin
WriteLnToConsole('Freeing resources...');
FreeActionsList();
- uVisualGears.freeModule;
StoreRelease();
ControllerClose();
CloseIPC();
@@ -200,14 +199,6 @@
end;
end;
-/////////////////////////
-procedure ShowMainWindow;
-begin
- if cFullScreen then ParseCommand('fullscr 1', true)
- else ParseCommand('fullscr 0', true);
- SDL_ShowCursor(0)
-end;
-
///////////////
{$IFDEF HWLIBRARY}
procedure Game(gameArgs: PPChar); cdecl; export;
@@ -239,7 +230,6 @@
cStereoMode:= smNone;
{$ENDIF}
- cLogfileBase:= 'game';
initEverything(true);
WriteLnToConsole('Hedgewars ' + cVersionString + ' engine (network protocol: ' + inttostr(cNetProtoVersion) + ')');
@@ -261,19 +251,15 @@
WriteLnToConsole(msgOK);
SDL_EnableUNICODE(1);
+ SDL_ShowCursor(0);
WriteToConsole('Init SDL_ttf... ');
SDLTry(TTF_Init() <> -1, true);
WriteLnToConsole(msgOK);
-{$IFDEF WIN32}
- s:= SDL_getenv('SDL_VIDEO_CENTERED');
- SDL_putenv('SDL_VIDEO_CENTERED=1');
- ShowMainWindow();
- SDL_putenv(str2pchar('SDL_VIDEO_CENTERED=' + s));
-{$ELSE}
- ShowMainWindow();
-{$ENDIF}
+ // show main window
+ if cFullScreen then ParseCommand('fullscr 1', true)
+ else ParseCommand('fullscr 0', true);
ControllerInit(); // has to happen before InitKbdKeyTable to map keys
InitKbdKeyTable();
@@ -335,6 +321,9 @@
begin
Randomize();
+ if complete then cLogfileBase:= 'game'
+ else cLogfileBase:= 'preview';
+
// uConsts does not need initialization as they are all consts
uUtils.initModule;
uMisc.initModule;
@@ -425,7 +414,6 @@
procedure GenLandPreview{$IFDEF HWLIBRARY}(port: LongInt); cdecl; export{$ENDIF};
var Preview: TPreview;
begin
- cLogfileBase:= 'preview';
initEverything(false);
{$IFDEF HWLIBRARY}
WriteLnToConsole('Preview connecting on port ' + inttostr(port));
@@ -496,9 +484,7 @@
else if GameType = gmtSyntax then DisplayUsage()
else Game();
- if GameType = gmtSyntax then
- ExitCode:= 1
- else
- ExitCode:= 0;
+ // return 1 when engine is not called correctly
+ ExitCode:= LongInt(GameType = gmtSyntax);
{$ENDIF}
end.
--- a/hedgewars/uRender.pas Sun Aug 14 17:49:12 2011 -0400
+++ b/hedgewars/uRender.pas Mon Aug 15 00:23:32 2011 +0200
@@ -70,7 +70,7 @@
begin
if (SourceTexture^.h = 0) or (SourceTexture^.w = 0) then exit;
-// don't draw anything outside the visible screen space (first check fixes some sprite drawing, e.g. hedgehogs)
+// do not draw anything outside the visible screen space (first check fixes some sprite drawing, e.g. hedgehogs)
if (abs(X) > W) and ((abs(X + W / 2) - W / 2) > cScreenWidth / cScaleFactor) then
exit;
if (abs(Y) > H) and ((abs(Y + H / 2 - (0.5 * cScreenHeight)) - H / 2) > cScreenHeight / cScaleFactor) then
@@ -139,7 +139,7 @@
hw, nx, ny: LongInt;
VertexBuffer, TextureBuffer: array [0..3] of TVertex2f;
begin
-// don't draw anything outside the visible screen space (first check fixes some sprite drawing, e.g. hedgehogs)
+// do not draw anything outside the visible screen space (first check fixes some sprite drawing, e.g. hedgehogs)
if (abs(X) > W) and ((abs(X + dir * OffsetX) - W / 2) * cScaleFactor > cScreenWidth) then
exit;
if (abs(Y) > H) and ((abs(Y + OffsetY - (0.5 * cScreenHeight)) - W / 2) * cScaleFactor > cScreenHeight) then
@@ -226,7 +226,7 @@
procedure DrawRotatedTex(Tex: PTexture; hw, hh, X, Y, Dir: LongInt; Angle: real);
var VertexBuffer: array [0..3] of TVertex2f;
begin
-// don't draw anything outside the visible screen space (first check fixes some sprite drawing, e.g. hedgehogs)
+// do not draw anything outside the visible screen space (first check fixes some sprite drawing, e.g. hedgehogs)
if (abs(X) > 2 * hw) and ((abs(X) - hw) > cScreenWidth / cScaleFactor) then
exit;
if (abs(Y) > 2 * hh) and ((abs(Y - 0.5 * cScreenHeight) - hh) > cScreenHeight / cScaleFactor) then
@@ -344,7 +344,7 @@
procedure DrawFillRect(r: TSDL_Rect);
var VertexBuffer: array [0..3] of TVertex2f;
begin
-// don't draw anything outside the visible screen space (first check fixes some sprite drawing, e.g. hedgehogs)
+// do not draw anything outside the visible screen space (first check fixes some sprite drawing, e.g. hedgehogs)
if (abs(r.x) > r.w) and ((abs(r.x + r.w / 2) - r.w / 2) * cScaleFactor > cScreenWidth) then
exit;
if (abs(r.y) > r.h) and ((abs(r.y + r.h / 2 - (0.5 * cScreenHeight)) - r.h / 2) * cScaleFactor > cScreenHeight) then
@@ -407,7 +407,7 @@
var l, r, t, b: real;
TextureBuffer: array [0..3] of TVertex2f;
begin
- // don't draw anything outside the visible screen space (first check fixes some sprite drawing, e.g. hedgehogs)
+ // do not draw anything outside the visible screen space (first check fixes some sprite drawing, e.g. hedgehogs)
if (abs(X) > 32) and ((abs(X) - 16) * cScaleFactor > cScreenWidth) then
exit;
if (abs(Y) > 32) and ((abs(Y - 0.5 * cScreenHeight) - 16) * cScaleFactor > cScreenHeight) then
--- a/hedgewars/uStore.pas Sun Aug 14 17:49:12 2011 -0400
+++ b/hedgewars/uStore.pas Mon Aug 15 00:23:32 2011 +0200
@@ -941,7 +941,7 @@
SDL_FreeSurface(ico)
end;
- // set window caption
+ // set window title
SDL_WM_SetCaption('Hedgewars', nil);
if SDLPrimSurface <> nil then
@@ -970,8 +970,13 @@
{$ELSE}
if not cOnlyStats then
begin
+{$IFDEF WIN32}
+ s:= SDL_getenv('SDL_VIDEO_CENTERED');
+ SDL_putenv('SDL_VIDEO_CENTERED=1');
+{$ENDIF}
SDLPrimSurface:= SDL_SetVideoMode(cScreenWidth, cScreenHeight, cBits, flags);
SDLTry(SDLPrimSurface <> nil, true);
+{$IFDEF WIN32}SDL_putenv(str2pchar('SDL_VIDEO_CENTERED=' + s));{$ENDIF}
end;
{$ENDIF}