From: Ketmar Dark Date: Mon, 25 Apr 2016 19:31:16 +0000 (+0300) Subject: "--log" cli arg; fixed bug with console output (endless loop) X-Git-Url: http://deadsoftware.ru/gitweb?a=commitdiff_plain;h=5b3da92681d54bd987d55c4a2649da65ebeb70ba;p=d2df-sdl.git "--log" cli arg; fixed bug with console output (endless loop) --- diff --git a/src/game/Doom2DF.dpr b/src/game/Doom2DF.dpr index a9044fb..3fbd829 100644 --- a/src/game/Doom2DF.dpr +++ b/src/game/Doom2DF.dpr @@ -117,7 +117,11 @@ var f: Integer; noct: Boolean = false; begin - for f := 1 to ParamCount do if ParamStr(f) = '--gdb' then noct := true; + for f := 1 to ParamCount do + begin + if ParamStr(f) = '--gdb' then noct := true + else if ParamStr(f) = '--log' then conbufDumpToStdOut := true; + end; if noct then Main() else diff --git a/src/game/g_console.pas b/src/game/g_console.pas index df45e6a..fcabed7 100644 --- a/src/game/g_console.pas +++ b/src/game/g_console.pas @@ -915,7 +915,7 @@ begin while length(L) > 0 do begin f := Pos(#10, L); - if f < 0 then f := length(L)+1; + if f <= 0 then f := length(L)+1; conmsg(Copy(L, 1, f-1)); Delete(L, 1, f); end; diff --git a/src/game/g_main.pas b/src/game/g_main.pas index e1e21d8..0d84cf2 100644 --- a/src/game/g_main.pas +++ b/src/game/g_main.pas @@ -62,6 +62,9 @@ begin e_WriteLog('Read config file', MSG_NOTIFY); g_Options_Read(GameDir + '/' + CONFIG_FILENAME); +{$IFDEF HEADLESS} + conbufDumpToStdOut := true; +{$ENDIF} e_WriteToStdOut := False; //{$IFDEF HEADLESS}True;{$ELSE}False;{$ENDIF} //GetSystemDefaultLCID() diff --git a/src/game/g_netmaster.pas b/src/game/g_netmaster.pas index adc285c..1f7ddf1 100644 --- a/src/game/g_netmaster.pas +++ b/src/game/g_netmaster.pas @@ -147,6 +147,7 @@ begin Cnt := e_Raw_Read_Byte(NetMEvent.packet^.data); e_WriteLog('Retrieved ' + IntToStr(Cnt) + ' server(s).', MSG_NOTIFY); g_Console_Add(_lc[I_NET_MSG] + Format(_lc[I_NET_SLIST_RETRIEVED], [Cnt]), True); + //writeln('BOO!'); if Cnt > 0 then begin diff --git a/src/shared/conbuf.pas b/src/shared/conbuf.pas index 57ed644..1be01b2 100644 --- a/src/shared/conbuf.pas +++ b/src/shared/conbuf.pas @@ -38,6 +38,9 @@ function cbufLineUp (var sp: LongWord; var ep: LongWord): Boolean; procedure cbufClear (); +var + conbufDumpToStdOut: Boolean = false; + implementation @@ -60,10 +63,9 @@ function cbufLastChange (): LongWord; begin result := changeCount; end; // ////////////////////////////////////////////////////////////////////////// // -{$IFDEF HEADLESS} var needCon: Boolean = true; -{$ENDIF} + procedure cbufPutChars (buf: PChar; count: Integer); var np: LongWord; @@ -71,15 +73,15 @@ var begin if count > 0 then begin -{$IFDEF HEADLESS} - //write(stderr, 'CON: '); - for np := 0 to count-1 do + if conbufDumpToStdOut then begin - if needCon then begin write(stdout, 'CON: '); needCon := false; end; - write(stdout, buf[np]); - needCon := (buf[np] = #10); + for np := 0 to count-1 do + begin + if needCon then begin write(stdout, 'CON: '); needCon := false; end; + write(stdout, buf[np]); + needCon := (buf[np] = #10); + end; end; -{$ENDIF} Inc(changeCount); if changeCount = 0 then changeCount := 1; while count > 0 do