hedgewars/uMisc.pas
changeset 2905 f3c79f7193a9
parent 2882 b9aceb3fe3d6
child 2915 a02f276035e8
equal deleted inserted replaced
2904:209a0c573917 2905:f3c79f7193a9
   127 
   127 
   128 
   128 
   129 procedure init_uMisc;
   129 procedure init_uMisc;
   130 procedure free_uMisc;
   130 procedure free_uMisc;
   131 procedure SplitBySpace(var a, b: shortstring);
   131 procedure SplitBySpace(var a, b: shortstring);
   132 procedure SplitByChar(var a, b: string; c: char);
   132 procedure SplitByChar(var a, b: ansistring; c: char);
   133 procedure movecursor(dx, dy: Integer);
   133 procedure movecursor(dx, dy: Integer);
   134 function  hwSign(r: hwFloat): LongInt;
   134 function  hwSign(r: hwFloat): LongInt;
   135 function  Min(a, b: LongInt): LongInt;
   135 function  Min(a, b: LongInt): LongInt;
   136 function  Max(a, b: LongInt): LongInt;
   136 function  Max(a, b: LongInt): LongInt;
   137 procedure OutError(Msg: String; isFatalError: boolean);
   137 procedure OutError(Msg: shortstring; isFatalError: boolean);
   138 procedure TryDo(Assert: boolean; Msg: string; isFatal: boolean);
   138 procedure TryDo(Assert: boolean; Msg: shortstring; isFatal: boolean);
   139 procedure SDLTry(Assert: boolean; isFatal: boolean);
   139 procedure SDLTry(Assert: boolean; isFatal: boolean);
   140 function  IntToStr(n: LongInt): shortstring;
   140 function  IntToStr(n: LongInt): shortstring;
   141 function  FloatToStr(n: hwFloat): shortstring;
   141 function  FloatToStr(n: hwFloat): shortstring;
   142 function  DxDy2Angle(const _dY, _dX: hwFloat): GLfloat;
   142 function  DxDy2Angle(const _dY, _dX: hwFloat): GLfloat;
   143 function  DxDy2Angle32(const _dY, _dX: hwFloat): LongInt;
   143 function  DxDy2Angle32(const _dY, _dX: hwFloat): LongInt;
   183 	b:= copy(a, i + 1, Length(a) - i);
   183 	b:= copy(a, i + 1, Length(a) - i);
   184 	byte(a[0]):= Pred(i)
   184 	byte(a[0]):= Pred(i)
   185 	end else b:= '';
   185 	end else b:= '';
   186 end;
   186 end;
   187 
   187 
   188 procedure SplitByChar(var a, b: string; c: char);
   188 procedure SplitByChar(var a, b: ansistring; c: char);
   189 var i: LongInt;
   189 var i: LongInt;
   190 begin
   190 begin
   191 i:= Pos(c, a);
   191 i:= Pos(c, a);
   192 if i > 0 then
   192 if i > 0 then
   193 	begin
   193 	begin
   194 	b:= copy(a, i + 1, Length(a) - i);
   194 	b:= copy(a, i + 1, Length(a) - i);
   195 	byte(a[0]):= Pred(i)
   195 	setlength(a, Pred(i));
   196 	end else b:= '';
   196 	end else b:= '';
   197 end;
   197 end;
   198 
   198 
   199 procedure movecursor(dx, dy: Integer);
   199 procedure movecursor(dx, dy: Integer);
   200 var x, y: LongInt;
   200 var x, y: LongInt;
   221 function Max(a, b: LongInt): LongInt;
   221 function Max(a, b: LongInt): LongInt;
   222 begin
   222 begin
   223 if a > b then Max:= a else Max:= b
   223 if a > b then Max:= a else Max:= b
   224 end;
   224 end;
   225 
   225 
   226 procedure OutError(Msg: String; isFatalError: boolean);
   226 procedure OutError(Msg: shortstring; isFatalError: boolean);
   227 begin
   227 begin
   228 {$IFDEF DEBUGFILE}AddFileLog(Msg);{$ENDIF}
   228 {$IFDEF DEBUGFILE}AddFileLog(Msg);{$ENDIF}
   229 WriteLnToConsole(Msg);
   229 WriteLnToConsole(Msg);
   230 if isFatalError then
   230 if isFatalError then
   231    begin
   231    begin
   233    SDL_Quit;
   233    SDL_Quit;
   234    halt(1)
   234    halt(1)
   235    end
   235    end
   236 end;
   236 end;
   237 
   237 
   238 procedure TryDo(Assert: boolean; Msg: string; isFatal: boolean);
   238 procedure TryDo(Assert: boolean; Msg: shortstring; isFatal: boolean);
   239 begin
   239 begin
   240 if not Assert then OutError(Msg, isFatal)
   240 if not Assert then OutError(Msg, isFatal)
   241 end;
   241 end;
   242 
   242 
   243 procedure SDLTry(Assert: boolean; isFatal: boolean);
   243 procedure SDLTry(Assert: boolean; isFatal: boolean);