DEADSOFTWARE

implement SDL1.2 system driver
[d2df-sdl.git] / src / game / g_basic.pas
index d82b285bf9f344afc9f906bb2c017f432916d055..22e318ab4a442a24e36759d25e764053a2011e03 100644 (file)
@@ -1,9 +1,8 @@
-(* Copyright (C)  DooM 2D:Forever Developers
+(* Copyright (C)  Doom 2D: Forever Developers
  *
  * This program is free software: you can redistribute it and/or modify
  * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation, either version 3 of the License, or
- * (at your option) any later version.
+ * the Free Software Foundation, version 3 of the License ONLY.
  *
  * This program is distributed in the hope that it will be useful,
  * but WITHOUT ANY WARRANTY; without even the implied warranty of
@@ -23,6 +22,8 @@ uses
 
 const
   GAME_VERSION  = '0.667';
+  GAME_BUILDDATE = {$I %DATE%};
+  GAME_BUILDTIME = {$I %TIME%};
   UID_GAME    = 1;
   UID_PLAYER  = 2;
   UID_MONSTER = 3;
@@ -87,7 +88,8 @@ function g_SetFileTime(fileName: String; time: Integer): Boolean;
 procedure SortSArray(var S: SSArray);
 function b_Text_Format(S: string): string;
 function b_Text_Unformat(S: string): string;
-
+function b_Text_Wrap(S: string; LineLen: Integer): string;
+function b_Text_LineCount(S: string): Integer;
 
 var
   gmon_dbg_los_enabled: Boolean = true;
@@ -687,6 +689,7 @@ var
   b: array of string;
   str: string;
 begin
+{
   SetLength(Result, 0);
   SetLength(b, 0);
 
@@ -713,7 +716,7 @@ begin
 
     if TextLen(str) > MaxWidth then
     begin // Òåêóùàÿ ñòðîêà ñëèøêîì äëèííàÿ => ðàçáèâàåì
-      while str <> '' do
+      while (str[0] <> #0) and (str <> '') do
       begin
         SetLength(Result, Length(Result)+1);
 
@@ -739,6 +742,8 @@ begin
       Result[High(Result)] := str;
     end;
   end;
+}
+  Result := nil
 end;
 
 procedure Sort(var a: SSArray);
@@ -1173,4 +1178,19 @@ begin
   end;
 end;
 
+function b_Text_Wrap(S: string; LineLen: Integer): string;
+begin
+  Result := WrapText(S, ''#10, [#10, ' ', '-'], LineLen);
+end;
+
+function b_Text_LineCount(S: string): Integer;
+var
+  I: Integer;
+begin
+  Result := IfThen(S = '', 0, 1);
+  for I := 1 to High(S) do
+    if S[I] = #10 then
+      Inc(Result);
+end;
+
 end.