From dfd3e97bffa213f5b21206b8a292b80180bab948 Mon Sep 17 00:00:00 2001 From: Ketmar Dark Date: Wed, 6 Apr 2016 00:58:36 +0300 Subject: [PATCH] warnings for -O3 --- src/engine/e_input.pas | 12 ++++++------ src/engine/e_log.pas | 2 +- src/game/g_basic.pas | 2 ++ src/game/g_console.pas | 3 +++ src/game/g_game.pas | 5 ++++- src/game/g_map.pas | 3 +++ src/game/g_monsters.pas | 4 +++- src/game/g_net.pas | 1 + src/game/g_netmsg.pas | 1 + src/game/g_playermodel.pas | 3 +++ src/game/g_res_downloader.pas | 1 + src/game/g_triggers.pas | 4 ++-- src/game/g_window.pas | 10 +++++++--- src/shared/WADEDITOR.pas | 1 + 14 files changed, 38 insertions(+), 14 deletions(-) diff --git a/src/engine/e_input.pas b/src/engine/e_input.pas index e8a03f7..67e0b5d 100644 --- a/src/engine/e_input.pas +++ b/src/engine/e_input.pas @@ -175,9 +175,10 @@ end; function PollJoysticks(): Boolean; var - i, j, d: Word; + i, j: Word; hat: Byte; begin + Result := False; if (Joysticks = nil) or (e_JoysticksAvailable = 0) then Exit; SDL_JoystickUpdate(); for j := Low(Joysticks) to High(Joysticks) do @@ -191,13 +192,12 @@ begin begin hat := SDL_JoystickGetHat(Handle, i); HatBuf[i, HAT_UP] := LongBool(hat and SDL_HAT_UP); - HatBuf[i, HAT_DOWN] := LongBool(hat and SDL_HAT_DOWN); - HatBuf[i, HAT_LEFT] := LongBool(hat and SDL_HAT_LEFT); - HatBuf[i, HAT_RIGHT] := LongBool(hat and SDL_HAT_RIGHT); + HatBuf[i, HAT_DOWN] := LongBool(hat and SDL_HAT_DOWN); + HatBuf[i, HAT_LEFT] := LongBool(hat and SDL_HAT_LEFT); + HatBuf[i, HAT_RIGHT] := LongBool(hat and SDL_HAT_RIGHT); end; end; - Result := False; -end; +end; procedure GenerateKeyNames(); var diff --git a/src/engine/e_log.pas b/src/engine/e_log.pas index b8a1850..b877db3 100644 --- a/src/engine/e_log.pas +++ b/src/engine/e_log.pas @@ -31,7 +31,7 @@ procedure e_WriteLog(TextLine: String; RecordCategory: TRecordCategory; WriteTime: Boolean = True); var LogFile: TextFile; - Prefix: ShortString; + Prefix: ShortString = ''; begin if FileName = '' then Exit; diff --git a/src/game/g_basic.pas b/src/game/g_basic.pas index e1ce980..4b505ab 100644 --- a/src/game/g_basic.pas +++ b/src/game/g_basic.pas @@ -614,6 +614,7 @@ function GetStr(var Str: string): string; var a: Integer; begin + Result := ''; for a := 1 to Length(Str) do if (a = Length(Str)) or (Str[a+1] = ' ') then begin @@ -852,6 +853,7 @@ begin n := 1; m := 1; Result := 0; + s1 := ''; for i := 0 to High(Pointers) do begin diff --git a/src/game/g_console.pas b/src/game/g_console.pas index 3c16037..fc78ef0 100644 --- a/src/game/g_console.pas +++ b/src/game/g_console.pas @@ -75,6 +75,7 @@ function GetStrACmd(var Str: String): String; var a: Integer; begin + Result := ''; for a := 1 to Length(Str) do if (a = Length(Str)) or (Str[a+1] = ';') then begin @@ -108,6 +109,7 @@ var F: TextFile; begin Cmd := LowerCase(P[0]); + s := ''; if Cmd = 'clear' then begin @@ -743,6 +745,7 @@ function GetStr(var Str: String): String; var a, b: Integer; begin + Result := ''; if Str[1] = '"' then begin for b := 1 to Length(Str) do diff --git a/src/game/g_game.pas b/src/game/g_game.pas index 9adfa22..13ffb10 100644 --- a/src/game/g_game.pas +++ b/src/game/g_game.pas @@ -821,6 +821,9 @@ var wad, map: string; mapstr: string; begin + s1 := ''; + s2 := ''; + s3 := ''; pc := g_Player_GetCount; e_TextureFontGetSize(gStdFont, cw, ch); @@ -4751,7 +4754,7 @@ var s, pw: String; chstr: string; cmd: string; - pl: pTNetClient; + pl: pTNetClient = nil; plr: TPlayer; prt: Word; nm: Boolean; diff --git a/src/game/g_map.pas b/src/game/g_map.pas index 9e14586..aa0c4cb 100644 --- a/src/game/g_map.pas +++ b/src/game/g_map.pas @@ -781,6 +781,8 @@ var begin Result := False; gMapInfo.Map := Res; + TriggersTable := nil; + FillChar(texture, SizeOf(texture), 0); // Çàãðóçêà WAD: g_ProcessResourceStr(Res, FileName, SectionName, ResName); @@ -1230,6 +1232,7 @@ var Data: Pointer; Len: Integer; begin + FillChar(Result, SizeOf(Result), 0); g_ProcessResourceStr(Res, FileName, SectionName, ResName); WAD := TWADEditor_1.Create(); diff --git a/src/game/g_monsters.pas b/src/game/g_monsters.pas index 507a560..1579019 100644 --- a/src/game/g_monsters.pas +++ b/src/game/g_monsters.pas @@ -1202,7 +1202,9 @@ end; function g_Monsters_GetNameByID(MonsterType: Byte): String; begin if MonsterType in [MONSTER_DEMON..MONSTER_MAN] then - Result := MONSTERTABLE[MonsterType].Name; + Result := MONSTERTABLE[MonsterType].Name + else + Result := '?'; end; function g_Monsters_GetKilledBy(MonsterType: Byte): String; diff --git a/src/game/g_net.pas b/src/game/g_net.pas index 74defc3..a1c0770 100644 --- a/src/game/g_net.pas +++ b/src/game/g_net.pas @@ -874,6 +874,7 @@ var Ptr: Pointer; msgStream: TMemoryStream; begin + FillChar(downloadEvent, SizeOf(downloadEvent), 0); msgStream := nil; OuterLoop := True; while OuterLoop do diff --git a/src/game/g_netmsg.pas b/src/game/g_netmsg.pas index 27b8081..7cc04d2 100644 --- a/src/game/g_netmsg.pas +++ b/src/game/g_netmsg.pas @@ -1624,6 +1624,7 @@ var pln: String; cnt: Byte; begin + FillChar(EvHash, Sizeof(EvHash), 0); EvType := e_Raw_Read_Byte(P); EvNum := e_Raw_Read_LongInt(P); EvStr := e_Raw_Read_String(P); diff --git a/src/game/g_playermodel.pas b/src/game/g_playermodel.pas index 283113e..a009823 100644 --- a/src/game/g_playermodel.pas +++ b/src/game/g_playermodel.pas @@ -165,6 +165,8 @@ var s: String; begin Result := False; + x := 0; + y := 0; str := Trim(str); if Length(str) < 3 then @@ -561,6 +563,7 @@ function g_PlayerModel_GetInfo(ModelName: string): TModelInfo; var a: Integer; begin + FillChar(Result, SizeOf(Result), 0); if PlayerModelsArray = nil then Exit; for a := 0 to High(PlayerModelsArray) do diff --git a/src/game/g_res_downloader.pas b/src/game/g_res_downloader.pas index e4959b7..9547335 100644 --- a/src/game/g_res_downloader.pas +++ b/src/game/g_res_downloader.pas @@ -108,6 +108,7 @@ var i: Integer; resData: TResDataMsg; begin + SetLength(mapData.ExternalResources, 0); g_Console_Add(Format(_lc[I_NET_MAP_DL], [FileName])); e_WriteLog('Downloading map `' + FileName + '` from server', MSG_NOTIFY); MC_SEND_MapRequest(); diff --git a/src/game/g_triggers.pas b/src/game/g_triggers.pas index 6748a00..d1b2c67 100644 --- a/src/game/g_triggers.pas +++ b/src/game/g_triggers.pas @@ -2330,6 +2330,8 @@ var k: Byte; p: TPlayer; begin + Result := nil; + if gTriggers = nil then Exit; case g_GetUIDType(UID) of @@ -2345,8 +2347,6 @@ begin else k := 0; end; - Result := nil; - for a := 0 to High(gTriggers) do if (gTriggers[a].TriggerType <> TRIGGER_NONE) and (gTriggers[a].TimeOut = 0) and diff --git a/src/game/g_window.pas b/src/game/g_window.pas index bb20c47..8427dd3 100644 --- a/src/game/g_window.pas +++ b/src/game/g_window.pas @@ -56,10 +56,12 @@ const // TODO: make a transition table or something function WCharToCP1251(wc: Word): Word; +var + n: Word; begin - for Result := 0 to 127 do - if CP1251[Result] = wc then - break; + Result := 0; + for n := 0 to 127 do + if CP1251[n] = wc then begin Result := n; break end; Result := Result + 128; end; @@ -354,6 +356,7 @@ var ev: TSDL_Event; ID: DWORD; begin + FillChar(ev, SizeOf(ev), 0); //wNeedFree := False; wLoadingProgress := True; while SDL_PollEvent(@ev) > 0 do @@ -398,6 +401,7 @@ var ev: TSDL_Event; begin Result := False; + FillChar(ev, SizeOf(ev), 0); while SDL_PollEvent(@ev) > 0 do begin diff --git a/src/shared/WADEDITOR.pas b/src/shared/WADEDITOR.pas index 3c6c1a3..83538c0 100644 --- a/src/shared/WADEDITOR.pas +++ b/src/shared/WADEDITOR.pas @@ -674,6 +674,7 @@ begin DFWAD_ERROR_WADNOTLOADED: Result := 'DFWAD file is not loaded'; DFWAD_ERROR_READRESOURCE: Result := 'Read resource error'; DFWAD_ERROR_READWAD: Result := 'Read DFWAD error'; + else Result := 'Unknown DFWAD error'; end; end; -- 2.29.2