Changeset 447 for trunk/LocalPlayer/Tribes.pas
- Timestamp:
- May 19, 2022, 10:39:34 PM (2 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/LocalPlayer/Tribes.pas
r438 r447 49 49 constructor Create(FileName: string); 50 50 destructor Destroy; override; 51 function GetCityName( i: Integer): string;52 {$IFNDEF SCR} procedure SetCityName( i: Integer; NewName: string); {$ENDIF}51 function GetCityName(I: Integer): string; 52 {$IFNDEF SCR} procedure SetCityName(I: Integer; NewName: string); {$ENDIF} 53 53 {$IFNDEF SCR} function TString(Template: string): string; 54 54 function TPhrase(Item: string): string; {$ENDIF} … … 74 74 procedure FindStdModelPicture(Code: Integer; var pix: Integer; var Name: string); 75 75 function GetTribeInfo(FileName: string; var Name: string; var Color: TColor): Boolean; 76 procedure FindPosition(HGr: TGraphicSet; x, y, xmax, ymax: Integer; Mark: TColor;76 procedure FindPosition(HGr: TGraphicSet; X, Y, xmax, ymax: Integer; Mark: TColor; 77 77 var xp, yp: Integer); 78 78 … … 215 215 function Get: string; 216 216 var 217 p: Integer;217 P: Integer; 218 218 begin 219 219 while (Input <> '') and ((Input[1] = ' ') or (Input[1] = #9)) do 220 220 Delete(Input, 1, 1); 221 p:= Pos(',', Input);222 if p= 0 then223 p:= Length(Input) + 1;224 Result := Copy(Input, 1, p- 1);225 Delete(Input, 1, p);221 P := Pos(',', Input); 222 if P = 0 then 223 P := Length(Input) + 1; 224 Result := Copy(Input, 1, P - 1); 225 Delete(Input, 1, P); 226 226 end; 227 227 228 228 function GetNum: Integer; 229 229 var 230 i: Integer;231 begin 232 Val(Get, Result, i);233 if i<> 0 then230 I: Integer; 231 begin 232 Val(Get, Result, I); 233 if I <> 0 then 234 234 Result := 0; 235 235 end; … … 237 237 procedure FindStdModelPicture(Code: Integer; var pix: Integer; var Name: string); 238 238 var 239 i: Integer;240 begin 241 for i:= 0 to StdUnitScript.Count - 1 do239 I: Integer; 240 begin 241 for I := 0 to StdUnitScript.Count - 1 do 242 242 begin // look through StdUnits 243 Input := StdUnitScript[ i];243 Input := StdUnitScript[I]; 244 244 pix := GetNum; 245 245 if Code = GetNum then … … 340 340 end; 341 341 342 procedure FindPosition(HGr: TGraphicSet; x, y, xmax, ymax: Integer; Mark: TColor;342 procedure FindPosition(HGr: TGraphicSet; X, Y, xmax, ymax: Integer; Mark: TColor; 343 343 var xp, yp: Integer); 344 344 begin 345 345 xp := 0; 346 while (xp < xmax) and (HGr.Data.Canvas.Pixels[ x + 1 + xp, y] <> Mark) do346 while (xp < xmax) and (HGr.Data.Canvas.Pixels[X + 1 + xp, Y] <> Mark) do 347 347 Inc(xp); 348 348 yp := 0; 349 while (yp < ymax) and (HGr.Data.Canvas.Pixels[ x, y+ 1 + yp] <> Mark) do349 while (yp < ymax) and (HGr.Data.Canvas.Pixels[X, Y + 1 + yp] <> Mark) do 350 350 Inc(yp); 351 351 end; 352 352 353 function TTribe.GetCityName( i: Integer): string;353 function TTribe.GetCityName(I: Integer): string; 354 354 begin 355 355 Result := ''; 356 if nCityLines > ithen357 begin 358 Result := Script[CityLine0 + i];356 if nCityLines > I then 357 begin 358 Result := Script[CityLine0 + I]; 359 359 while (Result <> '') and ((Result[1] = ' ') or (Result[1] = #9)) do 360 360 Delete(Result, 1, 1); … … 362 362 {$IFNDEF SCR} 363 363 else 364 Result := Format(TPhrase('GENCITY'), [ i+ 1]);364 Result := Format(TPhrase('GENCITY'), [I + 1]); 365 365 {$ENDIF} 366 366 end; 367 367 368 368 {$IFNDEF SCR} 369 procedure TTribe.SetCityName( i: Integer; NewName: string);370 begin 371 while nCityLines <= ido369 procedure TTribe.SetCityName(I: Integer; NewName: string); 370 begin 371 while nCityLines <= I do 372 372 begin 373 373 Script.Insert(CityLine0 + nCityLines, Format(TPhrase('GENCITY'), … … 375 375 Inc(nCityLines); 376 376 end; 377 Script[CityLine0 + i] := NewName;377 Script[CityLine0 + I] := NewName; 378 378 end; 379 379 380 380 function TTribe.TString(Template: string): string; 381 381 var 382 p: Integer;382 P: Integer; 383 383 Variant: Char; 384 384 CaseUp: Boolean; 385 385 begin 386 386 repeat 387 p := pos('#', Template);388 if ( p = 0) or (p= Length(Template)) then387 P := Pos('#', Template); 388 if (P = 0) or (P = Length(Template)) then 389 389 Break; 390 Variant := Template[ p+ 1];390 Variant := Template[P + 1]; 391 391 CaseUp := Variant in ['A' .. 'Z']; 392 392 if CaseUp then 393 393 Inc(Variant, 32); 394 Delete(Template, p, 2);394 Delete(Template, P, 2); 395 395 if Variant in ['a' .. 'z'] then 396 396 begin 397 397 if NumberName < 0 then 398 Insert(Name[Variant], Template, p)398 Insert(Name[Variant], Template, P) 399 399 else 400 Insert(Format('P%d', [NumberName]), Template, p);401 if CaseUp and (Length(Template) >= p) and402 (Template[ p] in ['a' .. 'z', #$E0 .. #$FF]) then403 Dec(Template[ p], 32);400 Insert(Format('P%d', [NumberName]), Template, P); 401 if CaseUp and (Length(Template) >= P) and 402 (Template[P] in ['a' .. 'z', #$E0 .. #$FF]) then 403 Dec(Template[P], 32); 404 404 end 405 405 until False; … … 418 418 TLine = array [0 .. 649, 0 .. 2] of Byte; 419 419 var 420 i, x, Gray: Integer;420 I, X, Gray: Integer; 421 421 Item: string; 422 422 begin … … 426 426 with Script do 427 427 begin 428 i:= 0;429 while ( i < Count) and (Copy(Strings[i], 1, 6) <>428 I := 0; 429 while (I < Count) and (Copy(Strings[I], 1, 6) <> 430 430 '#AGE' + char(48 + Age) + ' ') do 431 Inc( i);432 if i< Count then433 begin 434 Input := Strings[ i];431 Inc(I); 432 if I < Count then 433 begin 434 Input := Strings[I]; 435 435 system.Delete(Input, 1, 6); 436 436 Item := Get; … … 448 448 end; 449 449 cHGr := LoadGraphicSet(Item + '.png'); 450 for x:= 0 to 3 do451 with CityPicture[ x] do begin452 FindPosition(cHGr, x* 65, cpix * 49, 63, 47, $00FFFF,450 for X := 0 to 3 do 451 with CityPicture[X] do begin 452 FindPosition(cHGr, X * 65, cpix * 49, 63, 47, $00FFFF, 453 453 xShield, yShield); 454 454 // FindPosition(cHGr,x*65,cpix*49,$FFFFFF,xf,yf); … … 486 486 procedure TTribe.SetModelPicture(const Info: TModelPictureInfo; IsNew: Boolean); 487 487 var 488 i: Integer;488 I: Integer; 489 489 ok: Boolean; 490 490 begin … … 493 493 if not IsNew then 494 494 begin 495 i:= nPictureList - 1;496 while ( i >= 0) and (PictureList[i].Hash <> Info.Hash) do497 Dec( i);498 assert(i>= 0);499 assert(PictureList[i].HGr = LoadGraphicSet(GrName));500 assert(PictureList[i].pix = pix);501 ModelPicture[mix].HGr := PictureList[ i].HGr;502 ModelPicture[mix].pix := PictureList[ i].pix;503 ModelName[mix] := PictureList[ i].ModelName;495 I := nPictureList - 1; 496 while (I >= 0) and (PictureList[I].Hash <> Info.Hash) do 497 Dec(I); 498 Assert(I >= 0); 499 Assert(PictureList[I].HGr = LoadGraphicSet(GrName)); 500 Assert(PictureList[I].pix = pix); 501 ModelPicture[mix].HGr := PictureList[I].HGr; 502 ModelPicture[mix].pix := PictureList[I].pix; 503 ModelName[mix] := PictureList[I].ModelName; 504 504 end 505 505 else … … 515 515 // read model name from tribe script 516 516 ok := False; 517 for i:= 0 to Script.Count - 1 do518 begin 519 Input := Script[ i];517 for I := 0 to Script.Count - 1 do 518 begin 519 Input := Script[I]; 520 520 if Input = '#UNITS ' + ExtractFileNameOnly(GrName) then 521 521 ok := True … … 531 531 if ModelName[mix] = '' then 532 532 begin // read model name from StdUnits.txt 533 for i:= 0 to StdUnitScript.Count - 1 do533 for I := 0 to StdUnitScript.Count - 1 do 534 534 begin 535 Input := StdUnitScript[ i];535 Input := StdUnitScript[I]; 536 536 if GetNum = pix then 537 537 begin … … 567 567 Code, Turn: Integer; ForceNew: Boolean): Boolean; 568 568 var 569 i: Integer;569 I: Integer; 570 570 Cnt: Integer; 571 571 HGr: TGraphicSet; … … 606 606 if not ForceNew and (Picture.Hash > 0) then 607 607 begin 608 for i:= 0 to nPictureList - 1 do609 if PictureList[ i].Hash = Picture.Hash then610 begin 611 Picture.GrName := PictureList[ i].HGr.Name;612 Picture.pix := PictureList[ i].pix;608 for I := 0 to nPictureList - 1 do 609 if PictureList[I].Hash = Picture.Hash then 610 begin 611 Picture.GrName := PictureList[I].HGr.Name; 612 Picture.pix := PictureList[I].pix; 613 613 Result := False; 614 614 Exit; … … 622 622 TestPic.GrName := 'StdUnits.png'; 623 623 HGr := HGrStdUnits; 624 for i:= 0 to StdUnitScript.Count - 1 do624 for I := 0 to StdUnitScript.Count - 1 do 625 625 begin // look through StdUnits 626 Input := StdUnitScript[ i];626 Input := StdUnitScript[I]; 627 627 Check; 628 628 end; 629 629 630 630 ok := False; 631 for i:= 0 to Script.Count - 1 do631 for I := 0 to Script.Count - 1 do 632 632 begin // look through units defined in tribe script 633 Input := Script[ i];633 Input := Script[I]; 634 634 if Copy(Input, 1, 6) = '#UNITS' then 635 635 begin
Note:
See TracChangeset
for help on using the changeset viewer.