- Timestamp:
- May 8, 2020, 11:15:17 AM (5 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/LocalPlayer/Term.pas
r190 r202 235 235 Closable, RepaintOnResize, Tracking, TurnComplete, Edited, GoOnPhase, 236 236 HaveStrategyAdvice, FirstMovieTurn: boolean; 237 function ChooseUnusedTribe: integer; 238 procedure GetTribeList; 239 procedure InitModule; 240 procedure InitTurn(NewPlayer: integer); 237 241 procedure ScrollBarUpdate(Sender: TObject); 238 242 procedure ArrangeMidPanel; … … 272 276 procedure SetTileSize(x, y: integer); 273 277 procedure RectInvalidate(Left, Top, Rigth, Bottom: integer); 278 procedure ShowEnemyShipChange(ShowShipChange: TShowShipChange); 274 279 procedure SmartRectInvalidate(Left, Top, Rigth, Bottom: integer); 275 280 procedure LoadSettings; … … 277 282 procedure OnScroll(var m: TMessage); message WM_VSCROLL; 278 283 procedure OnEOT(var Msg: TMessage); message WM_EOT; 284 procedure SoundPreload(Check: integer); 279 285 public 280 286 UsedOffscreenWidth, UsedOffscreenHeight: integer; … … 393 399 'CITY_WONDEREX', 'CITY_EMDELAY', 'CITY_FOUNDED', 'CITY_FOUNDED', '', 394 400 'CITY_INVALIDTYPE'); 401 402 // sound blocks for preload 403 sbStart = $01; 404 sbWonder = $02; 405 sbScience = $04; 406 sbContact = $08; 407 sbTurn = $10; 408 sbAll = $FF; 395 409 396 410 type … … 1295 1309 end; 1296 1310 1297 procedure TMainScreen.Client(Command, NewPlayer: integer; var Data); 1298 1299 procedure GetTribeList; 1300 var 1301 SearchRec: TSearchRec; 1302 Color: TColor; 1303 Name: string; 1304 ok: boolean; 1305 begin 1306 UnusedTribeFiles.Clear; 1307 ok := FindFirst(LocalizedFilePath('Tribes') + DirectorySeparator + '*.tribe.txt', 1311 procedure TMainScreen.SoundPreload(Check: integer); 1312 const 1313 nStartBlock = 27; 1314 StartBlock: array [0 .. nStartBlock - 1] of string = ('INVALID', 'TURNEND', 1315 'DISBAND', 'CHEAT', 'MSG_DEFAULT', 'WARNING_DISORDER', 'WARNING_FAMINE', 1316 'WARNING_LOWSUPPORT', 'WARNING_LOWFUNDS', 'MOVE_MOUNTAIN', 'MOVE_LOAD', 1317 'MOVE_UNLOAD', 'MOVE_DIE', 'NOMOVE_TIME', 'NOMOVE_DOMAIN', 1318 'NOMOVE_DEFAULT', 'CITY_SELLIMP', 'CITY_REBUILDIMP', 'CITY_BUYPROJECT', 1319 'CITY_UTILIZE', 'NEWMODEL_0', 'NEWADVANCE_0', 'AGE_0', 'REVOLUTION', 1320 'NEWGOV', 'CITY_INVALIDTYPE', 'MSG_GAMEOVER'); 1321 1322 nWonderBlock = 6; 1323 WonderBlock: array [0 .. nWonderBlock - 1] of string = ('WONDER_BUILT', 1324 'WONDER_CAPTURED', 'WONDER_EXPIRED', 'WONDER_DESTROYED', 'MSG_COLDWAR', 1325 'NEWADVANCE_GRLIB'); 1326 1327 nScienceBlock = 17; 1328 ScienceBlock: array [0 .. nScienceBlock - 1] of string = ('MOVE_PARACHUTE', 1329 'MOVE_PLANESTART', 'MOVE_PLANELANDING', 'MOVE_COVERT', 'NEWMODEL_1', 1330 'NEWMODEL_2', 'NEWMODEL_3', 'NEWADVANCE_1', 'NEWADVANCE_2', 1331 'NEWADVANCE_3', 'AGE_1', 'AGE_2', 'AGE_3', 'SHIP_BUILT', 'SHIP_TRADED', 1332 'SHIP_CAPTURED', 'SHIP_DESTROYED'); 1333 1334 nContactBlock = 20; 1335 ContactBlock: array [0 .. nContactBlock - 1] of string = ('NEWTREATY', 1336 'CANCELTREATY', 'ACCEPTOFFER', 'MSG_WITHDRAW', 'MSG_BANKRUPT', 1337 'CONTACT_0', 'CONTACT_1', 'CONTACT_2', 'CONTACT_3', 'CONTACT_4', 1338 'CONTACT_5', 'CONTACT_5', 'CONTACT_6', 'NEGO_REJECTED', 'MOVE_CAPTURE', 1339 'MOVE_EXPEL', 'NOMOVE_TREATY', 'NOMOVE_ZOC', 'NOMOVE_SUBMARINE', 1340 'NOMOVE_STEALTH'); 1341 1342 var 1343 i, cix, mix: integer; 1344 need: boolean; 1345 mi: TModelInfo; 1346 begin 1347 if Check and sbStart and not SoundPreloadDone <> 0 then 1348 begin 1349 for i := 0 to nStartBlock - 1 do 1350 PreparePlay(StartBlock[i]); 1351 SoundPreloadDone := SoundPreloadDone or sbStart; 1352 end; 1353 if Check and sbWonder and not SoundPreloadDone <> 0 then 1354 begin 1355 need := false; 1356 for i := 0 to 27 do 1357 if MyRO.Wonder[i].CityID <> -1 then 1358 need := true; 1359 if need then 1360 begin 1361 for i := 0 to nWonderBlock - 1 do 1362 PreparePlay(WonderBlock[i]); 1363 SoundPreloadDone := SoundPreloadDone or sbWonder; 1364 end; 1365 end; 1366 if (Check and sbScience and not SoundPreloadDone <> 0) and 1367 (MyRO.Tech[adScience] >= tsApplicable) then 1368 begin 1369 for i := 0 to nScienceBlock - 1 do 1370 PreparePlay(ScienceBlock[i]); 1371 SoundPreloadDone := SoundPreloadDone or sbScience; 1372 end; 1373 if (Check and sbContact and not SoundPreloadDone <> 0) and 1374 (MyRO.nEnemyModel + MyRO.nEnemyCity > 0) then 1375 begin 1376 for i := 0 to nContactBlock - 1 do 1377 PreparePlay(ContactBlock[i]); 1378 SoundPreloadDone := SoundPreloadDone or sbContact; 1379 end; 1380 if Check and sbTurn <> 0 then 1381 begin 1382 if MyRO.Happened and phShipComplete <> 0 then 1383 PreparePlay('MSG_YOUWIN'); 1384 if MyData.ToldAlive <> MyRO.Alive then 1385 PreparePlay('MSG_EXTINCT'); 1386 for cix := 0 to MyRO.nCity - 1 do 1387 with MyCity[cix] do 1388 if (Loc >= 0) and (Flags and CityRepMask <> 0) then 1389 for i := 0 to 12 do 1390 if 1 shl i and Flags and CityRepMask <> 0 then 1391 PreparePlay(CityEventSoundItem[i]); 1392 for mix := 0 to MyRO.nModel - 1 do 1393 with MyModel[mix] do 1394 if Attack > 0 then 1395 begin 1396 MakeModelInfo(me, mix, MyModel[mix], mi); 1397 PreparePlay(AttackSound(ModelCode(mi))); 1398 end; 1399 end; 1400 end; 1401 1402 procedure TMainScreen.GetTribeList; 1403 var 1404 SearchRec: TSearchRec; 1405 Color: TColor; 1406 Name: string; 1407 ok: boolean; 1408 begin 1409 UnusedTribeFiles.Clear; 1410 ok := FindFirst(LocalizedFilePath('Tribes') + DirectorySeparator + '*.tribe.txt', 1411 faArchive + faReadOnly, SearchRec) = 0; 1412 if not ok then 1413 begin 1414 FindClose(SearchRec); 1415 ok := FindFirst(LocalizedFilePath('Tribes' + DirectorySeparator + '*.tribe.txt'), 1308 1416 faArchive + faReadOnly, SearchRec) = 0; 1309 if not ok then 1310 begin 1311 FindClose(SearchRec); 1312 ok := FindFirst(LocalizedFilePath('Tribes' + DirectorySeparator + '*.tribe.txt'), 1313 faArchive + faReadOnly, SearchRec) = 0; 1417 end; 1418 if ok then 1419 repeat 1420 SearchRec.Name := Copy(SearchRec.Name, 1, Length(SearchRec.Name) - 10); 1421 if GetTribeInfo(SearchRec.Name, Name, Color) then 1422 UnusedTribeFiles.AddObject(SearchRec.Name, TObject(Color)); 1423 until FindNext(SearchRec) <> 0; 1424 FindClose(SearchRec); 1425 end; 1426 1427 function TMainScreen.ChooseUnusedTribe: integer; 1428 var 1429 i, j, ColorDistance, BestColorDistance, TestColorDistance, 1430 CountBest: integer; 1431 begin 1432 assert(UnusedTribeFiles.Count > 0); 1433 result := -1; 1434 BestColorDistance := -1; 1435 for j := 0 to UnusedTribeFiles.Count - 1 do 1436 begin 1437 ColorDistance := 250; // consider differences more than this infinite 1438 for i := 0 to nPl - 1 do 1439 if Tribe[i] <> nil then 1440 begin 1441 TestColorDistance := abs(integer(UnusedTribeFiles.Objects[j]) 1442 shr 16 and $FF - Tribe[i].Color shr 16 and $FF) + 1443 abs(integer(UnusedTribeFiles.Objects[j]) shr 8 and 1444 $FF - Tribe[i].Color shr 8 and $FF) * 3 + 1445 abs(integer(UnusedTribeFiles.Objects[j]) and 1446 $FF - Tribe[i].Color and $FF) * 2; 1447 if TestColorDistance < ColorDistance then 1448 ColorDistance := TestColorDistance 1449 end; 1450 if ColorDistance > BestColorDistance then 1451 begin 1452 CountBest := 0; 1453 BestColorDistance := ColorDistance 1314 1454 end; 1315 if ok then 1316 repeat 1317 SearchRec.Name := Copy(SearchRec.Name, 1, Length(SearchRec.Name) - 10); 1318 if GetTribeInfo(SearchRec.Name, Name, Color) then 1319 UnusedTribeFiles.AddObject(SearchRec.Name, TObject(Color)); 1320 until FindNext(SearchRec) <> 0; 1321 FindClose(SearchRec); 1322 end; 1323 1324 function ChooseUnusedTribe: integer; 1325 var 1326 i, j, ColorDistance, BestColorDistance, TestColorDistance, 1327 CountBest: integer; 1328 begin 1329 assert(UnusedTribeFiles.Count > 0); 1330 result := -1; 1331 BestColorDistance := -1; 1332 for j := 0 to UnusedTribeFiles.Count - 1 do 1333 begin 1334 ColorDistance := 250; // consider differences more than this infinite 1335 for i := 0 to nPl - 1 do 1336 if Tribe[i] <> nil then 1337 begin 1338 TestColorDistance := abs(integer(UnusedTribeFiles.Objects[j]) 1339 shr 16 and $FF - Tribe[i].Color shr 16 and $FF) + 1340 abs(integer(UnusedTribeFiles.Objects[j]) shr 8 and 1341 $FF - Tribe[i].Color shr 8 and $FF) * 3 + 1342 abs(integer(UnusedTribeFiles.Objects[j]) and 1343 $FF - Tribe[i].Color and $FF) * 2; 1344 if TestColorDistance < ColorDistance then 1345 ColorDistance := TestColorDistance 1455 if ColorDistance = BestColorDistance then 1456 begin 1457 inc(CountBest); 1458 if DelphiRandom(CountBest) = 0 then 1459 result := j 1460 end 1461 end; 1462 end; 1463 1464 procedure TMainScreen.ShowEnemyShipChange(ShowShipChange: TShowShipChange); 1465 var 1466 i, TestCost, MostCost: integer; 1467 Ship1Plus, Ship2Plus: boolean; 1468 begin 1469 with ShowShipChange, MessgExDlg do 1470 begin 1471 case Reason of 1472 scrProduction: 1473 begin 1474 OpenSound := 'SHIP_BUILT'; 1475 MessgText := Tribe[Ship1Owner].TPhrase('SHIPBUILT'); 1476 IconKind := mikShip; 1477 IconIndex := Ship1Owner; 1346 1478 end; 1347 if ColorDistance > BestColorDistance then 1348 begin 1349 CountBest := 0; 1350 BestColorDistance := ColorDistance 1479 1480 scrDestruction: 1481 begin 1482 OpenSound := 'SHIP_DESTROYED'; 1483 MessgText := Tribe[Ship1Owner].TPhrase('SHIPDESTROYED'); 1484 IconKind := mikImp; 1485 end; 1486 1487 scrTrade: 1488 begin 1489 OpenSound := 'SHIP_TRADED'; 1490 Ship1Plus := false; 1491 Ship2Plus := false; 1492 for i := 0 to nShipPart - 1 do 1493 begin 1494 if Ship1Change[i] > 0 then 1495 Ship1Plus := true; 1496 if Ship2Change[i] > 0 then 1497 Ship2Plus := true; 1498 end; 1499 if Ship1Plus and Ship2Plus then 1500 MessgText := Tribe[Ship1Owner].TPhrase('SHIPBITRADE1') + ' ' + 1501 Tribe[Ship2Owner].TPhrase('SHIPBITRADE2') 1502 else if Ship1Plus then 1503 MessgText := Tribe[Ship1Owner].TPhrase('SHIPUNITRADE1') + ' ' + 1504 Tribe[Ship2Owner].TPhrase('SHIPUNITRADE2') 1505 else // if Ship2Plus then 1506 MessgText := Tribe[Ship2Owner].TPhrase('SHIPUNITRADE1') + ' ' + 1507 Tribe[Ship1Owner].TPhrase('SHIPUNITRADE2'); 1508 IconKind := mikImp; 1509 end; 1510 1511 scrCapture: 1512 begin 1513 OpenSound := 'SHIP_CAPTURED'; 1514 MessgText := Tribe[Ship2Owner].TPhrase('SHIPCAPTURE1') + ' ' + 1515 Tribe[Ship1Owner].TPhrase('SHIPCAPTURE2'); 1516 IconKind := mikShip; 1517 IconIndex := Ship2Owner; 1518 end 1519 end; 1520 1521 if IconKind = mikImp then 1522 begin 1523 MostCost := 0; 1524 for i := 0 to nShipPart - 1 do 1525 begin 1526 TestCost := abs(Ship1Change[i]) * Imp[imShipComp + i].Cost; 1527 if TestCost > MostCost then 1528 begin 1529 MostCost := TestCost; 1530 IconIndex := imShipComp + i 1531 end 1351 1532 end; 1352 if ColorDistance = BestColorDistance then1353 begin1354 inc(CountBest);1355 if DelphiRandom(CountBest) = 0 then1356 result := j1357 end1358 1533 end; 1359 end; 1360 1361 procedure ShowEnemyShipChange(ShowShipChange: TShowShipChange); 1362 var 1363 i, TestCost, MostCost: integer; 1364 Ship1Plus, Ship2Plus: boolean; 1365 begin 1366 with ShowShipChange, MessgExDlg do 1367 begin 1368 case Reason of 1369 scrProduction: 1370 begin 1371 OpenSound := 'SHIP_BUILT'; 1372 MessgText := Tribe[Ship1Owner].TPhrase('SHIPBUILT'); 1373 IconKind := mikShip; 1374 IconIndex := Ship1Owner; 1375 end; 1376 1377 scrDestruction: 1378 begin 1379 OpenSound := 'SHIP_DESTROYED'; 1380 MessgText := Tribe[Ship1Owner].TPhrase('SHIPDESTROYED'); 1381 IconKind := mikImp; 1382 end; 1383 1384 scrTrade: 1385 begin 1386 OpenSound := 'SHIP_TRADED'; 1387 Ship1Plus := false; 1388 Ship2Plus := false; 1389 for i := 0 to nShipPart - 1 do 1390 begin 1391 if Ship1Change[i] > 0 then 1392 Ship1Plus := true; 1393 if Ship2Change[i] > 0 then 1394 Ship2Plus := true; 1395 end; 1396 if Ship1Plus and Ship2Plus then 1397 MessgText := Tribe[Ship1Owner].TPhrase('SHIPBITRADE1') + ' ' + 1398 Tribe[Ship2Owner].TPhrase('SHIPBITRADE2') 1399 else if Ship1Plus then 1400 MessgText := Tribe[Ship1Owner].TPhrase('SHIPUNITRADE1') + ' ' + 1401 Tribe[Ship2Owner].TPhrase('SHIPUNITRADE2') 1402 else // if Ship2Plus then 1403 MessgText := Tribe[Ship2Owner].TPhrase('SHIPUNITRADE1') + ' ' + 1404 Tribe[Ship1Owner].TPhrase('SHIPUNITRADE2'); 1405 IconKind := mikImp; 1406 end; 1407 1408 scrCapture: 1409 begin 1410 OpenSound := 'SHIP_CAPTURED'; 1411 MessgText := Tribe[Ship2Owner].TPhrase('SHIPCAPTURE1') + ' ' + 1412 Tribe[Ship1Owner].TPhrase('SHIPCAPTURE2'); 1413 IconKind := mikShip; 1414 IconIndex := Ship2Owner; 1415 end 1416 end; 1417 1418 if IconKind = mikImp then 1419 begin 1420 MostCost := 0; 1421 for i := 0 to nShipPart - 1 do 1422 begin 1423 TestCost := abs(Ship1Change[i]) * Imp[imShipComp + i].Cost; 1424 if TestCost > MostCost then 1425 begin 1426 MostCost := TestCost; 1427 IconIndex := imShipComp + i 1428 end 1429 end; 1430 end; 1431 1432 Kind := mkOk; 1433 ShowModal; 1434 end; 1435 end; 1436 1437 procedure InitModule; 1438 var 1439 x, y, i, j, Domain: integer; 1440 begin 1441 { search icons for advances: } 1442 for i := 0 to nAdv - 1 do 1443 if i in FutureTech then 1444 AdvIcon[i] := 96 + i - futResearchTechnology 1445 else 1446 begin 1447 AdvIcon[i] := -1; 1448 for Domain := 0 to nDomains - 1 do 1449 for j := 0 to nUpgrade - 1 do 1450 if upgrade[Domain, j].Preq = i then 1451 if AdvIcon[i] >= 0 then 1534 1535 Kind := mkOk; 1536 ShowModal; 1537 end; 1538 end; 1539 1540 procedure TMainScreen.InitModule; 1541 var 1542 x, y, i, j, Domain: integer; 1543 begin 1544 { search icons for advances: } 1545 for i := 0 to nAdv - 1 do 1546 if i in FutureTech then 1547 AdvIcon[i] := 96 + i - futResearchTechnology 1548 else 1549 begin 1550 AdvIcon[i] := -1; 1551 for Domain := 0 to nDomains - 1 do 1552 for j := 0 to nUpgrade - 1 do 1553 if upgrade[Domain, j].Preq = i then 1554 if AdvIcon[i] >= 0 then 1555 AdvIcon[i] := 85 1556 else 1557 AdvIcon[i] := 86 + Domain; 1558 for j := 0 to nFeature - 1 do 1559 if Feature[j].Preq = i then 1560 for Domain := 0 to nDomains - 1 do 1561 if 1 shl Domain and Feature[j].Domains <> 0 then 1562 if (AdvIcon[i] >= 0) and (AdvIcon[i] <> 86 + Domain) then 1452 1563 AdvIcon[i] := 85 1453 1564 else 1454 1565 AdvIcon[i] := 86 + Domain; 1455 for j := 0 to nFeature - 1 do 1456 if Feature[j].Preq = i then 1457 for Domain := 0 to nDomains - 1 do 1458 if 1 shl Domain and Feature[j].Domains <> 0 then 1459 if (AdvIcon[i] >= 0) and (AdvIcon[i] <> 86 + Domain) then 1460 AdvIcon[i] := 85 1461 else 1462 AdvIcon[i] := 86 + Domain; 1463 for j := 28 to nImp - 1 do 1464 if Imp[j].Preq = i then 1465 AdvIcon[i] := j; 1466 for j := 28 to nImp - 1 do 1467 if (Imp[j].Preq = i) and (Imp[j].Kind <> ikCommon) then 1468 AdvIcon[i] := j; 1469 for j := 0 to nJob - 1 do 1470 if i = JobPreq[j] then 1471 AdvIcon[i] := 84; 1472 for j := 0 to 27 do 1473 if Imp[j].Preq = i then 1474 AdvIcon[i] := j; 1475 if AdvIcon[i] < 0 then 1476 if AdvValue[i] < 1000 then 1477 AdvIcon[i] := -7 1478 else 1479 AdvIcon[i] := 24 + AdvValue[i] div 1000; 1480 for j := 2 to nGov - 1 do 1481 if GovPreq[j] = i then 1482 AdvIcon[i] := j - 8; 1483 end; 1484 AdvIcon[adConscription] := 86 + dGround; 1485 1486 UnusedTribeFiles := tstringlist.Create; 1487 UnusedTribeFiles.Sorted := true; 1488 TribeNames := tstringlist.Create; 1489 1490 for x := 0 to 11 do 1491 for y := 0 to 1 do 1492 MiniColors[x, y] := GrExt[HGrSystem].Data.Canvas.Pixels[66 + x, 67 + y]; 1493 IsoEngine.Init(InitEnemyModel); 1494 if not IsoEngine.ApplyTileSize(xxt, yyt) and ((xxt <> 48) or (yyt <> 24) or (xxt <> 72)) 1495 then 1496 ApplyTileSize(48, 24); 1497 // non-default tile size is missing a file, switch to default 1498 MainMap := TIsoMap.Create; 1499 MainMap.SetOutput(offscreen); 1500 1501 HGrStdUnits := LoadGraphicSet('StdUnits.png'); 1502 SmallImp := TBitmap.Create; 1503 SmallImp.PixelFormat := pf24bit; 1504 InitSmallImp; 1505 SoundPreloadDone := 0; 1506 StartRunning := false; 1507 StayOnTop_Ensured := false; 1508 1509 sb := TPVScrollbar.Create(Self); 1510 sb.OnUpdate := ScrollBarUpdate; 1511 end; { InitModule } 1512 1513 // sound blocks for preload 1566 for j := 28 to nImp - 1 do 1567 if Imp[j].Preq = i then 1568 AdvIcon[i] := j; 1569 for j := 28 to nImp - 1 do 1570 if (Imp[j].Preq = i) and (Imp[j].Kind <> ikCommon) then 1571 AdvIcon[i] := j; 1572 for j := 0 to nJob - 1 do 1573 if i = JobPreq[j] then 1574 AdvIcon[i] := 84; 1575 for j := 0 to 27 do 1576 if Imp[j].Preq = i then 1577 AdvIcon[i] := j; 1578 if AdvIcon[i] < 0 then 1579 if AdvValue[i] < 1000 then 1580 AdvIcon[i] := -7 1581 else 1582 AdvIcon[i] := 24 + AdvValue[i] div 1000; 1583 for j := 2 to nGov - 1 do 1584 if GovPreq[j] = i then 1585 AdvIcon[i] := j - 8; 1586 end; 1587 AdvIcon[adConscription] := 86 + dGround; 1588 1589 UnusedTribeFiles := tstringlist.Create; 1590 UnusedTribeFiles.Sorted := true; 1591 TribeNames := tstringlist.Create; 1592 1593 for x := 0 to 11 do 1594 for y := 0 to 1 do 1595 MiniColors[x, y] := GrExt[HGrSystem].Data.Canvas.Pixels[66 + x, 67 + y]; 1596 IsoEngine.Init(InitEnemyModel); 1597 if not IsoEngine.ApplyTileSize(xxt, yyt) and ((xxt <> 48) or (yyt <> 24) or (xxt <> 72)) 1598 then 1599 ApplyTileSize(48, 24); 1600 // non-default tile size is missing a file, switch to default 1601 MainMap := TIsoMap.Create; 1602 MainMap.SetOutput(offscreen); 1603 1604 HGrStdUnits := LoadGraphicSet('StdUnits.png'); 1605 SmallImp := TBitmap.Create; 1606 SmallImp.PixelFormat := pf24bit; 1607 InitSmallImp; 1608 SoundPreloadDone := 0; 1609 StartRunning := false; 1610 StayOnTop_Ensured := false; 1611 1612 sb := TPVScrollbar.Create(Self); 1613 sb.OnUpdate := ScrollBarUpdate; 1614 end; { InitModule } 1615 1616 procedure TMainScreen.InitTurn(NewPlayer: integer); 1514 1617 const 1515 sbStart = $01; 1516 sbWonder = $02; 1517 sbScience = $04; 1518 sbContact = $08; 1519 sbTurn = $10; 1520 sbAll = $FF; 1521 1522 procedure SoundPreload(Check: integer); 1523 const 1524 nStartBlock = 27; 1525 StartBlock: array [0 .. nStartBlock - 1] of string = ('INVALID', 'TURNEND', 1526 'DISBAND', 'CHEAT', 'MSG_DEFAULT', 'WARNING_DISORDER', 'WARNING_FAMINE', 1527 'WARNING_LOWSUPPORT', 'WARNING_LOWFUNDS', 'MOVE_MOUNTAIN', 'MOVE_LOAD', 1528 'MOVE_UNLOAD', 'MOVE_DIE', 'NOMOVE_TIME', 'NOMOVE_DOMAIN', 1529 'NOMOVE_DEFAULT', 'CITY_SELLIMP', 'CITY_REBUILDIMP', 'CITY_BUYPROJECT', 1530 'CITY_UTILIZE', 'NEWMODEL_0', 'NEWADVANCE_0', 'AGE_0', 'REVOLUTION', 1531 'NEWGOV', 'CITY_INVALIDTYPE', 'MSG_GAMEOVER'); 1532 1533 nWonderBlock = 6; 1534 WonderBlock: array [0 .. nWonderBlock - 1] of string = ('WONDER_BUILT', 1535 'WONDER_CAPTURED', 'WONDER_EXPIRED', 'WONDER_DESTROYED', 'MSG_COLDWAR', 1536 'NEWADVANCE_GRLIB'); 1537 1538 nScienceBlock = 17; 1539 ScienceBlock: array [0 .. nScienceBlock - 1] of string = ('MOVE_PARACHUTE', 1540 'MOVE_PLANESTART', 'MOVE_PLANELANDING', 'MOVE_COVERT', 'NEWMODEL_1', 1541 'NEWMODEL_2', 'NEWMODEL_3', 'NEWADVANCE_1', 'NEWADVANCE_2', 1542 'NEWADVANCE_3', 'AGE_1', 'AGE_2', 'AGE_3', 'SHIP_BUILT', 'SHIP_TRADED', 1543 'SHIP_CAPTURED', 'SHIP_DESTROYED'); 1544 1545 nContactBlock = 20; 1546 ContactBlock: array [0 .. nContactBlock - 1] of string = ('NEWTREATY', 1547 'CANCELTREATY', 'ACCEPTOFFER', 'MSG_WITHDRAW', 'MSG_BANKRUPT', 1548 'CONTACT_0', 'CONTACT_1', 'CONTACT_2', 'CONTACT_3', 'CONTACT_4', 1549 'CONTACT_5', 'CONTACT_5', 'CONTACT_6', 'NEGO_REJECTED', 'MOVE_CAPTURE', 1550 'MOVE_EXPEL', 'NOMOVE_TREATY', 'NOMOVE_ZOC', 'NOMOVE_SUBMARINE', 1551 'NOMOVE_STEALTH'); 1552 1553 var 1554 i, cix, mix: integer; 1555 need: boolean; 1556 mi: TModelInfo; 1557 begin 1558 if Check and sbStart and not SoundPreloadDone <> 0 then 1559 begin 1560 for i := 0 to nStartBlock - 1 do 1561 PreparePlay(StartBlock[i]); 1562 SoundPreloadDone := SoundPreloadDone or sbStart; 1563 end; 1564 if Check and sbWonder and not SoundPreloadDone <> 0 then 1565 begin 1566 need := false; 1567 for i := 0 to 27 do 1568 if MyRO.Wonder[i].CityID <> -1 then 1569 need := true; 1570 if need then 1571 begin 1572 for i := 0 to nWonderBlock - 1 do 1573 PreparePlay(WonderBlock[i]); 1574 SoundPreloadDone := SoundPreloadDone or sbWonder; 1575 end; 1576 end; 1577 if (Check and sbScience and not SoundPreloadDone <> 0) and 1578 (MyRO.Tech[adScience] >= tsApplicable) then 1579 begin 1580 for i := 0 to nScienceBlock - 1 do 1581 PreparePlay(ScienceBlock[i]); 1582 SoundPreloadDone := SoundPreloadDone or sbScience; 1583 end; 1584 if (Check and sbContact and not SoundPreloadDone <> 0) and 1585 (MyRO.nEnemyModel + MyRO.nEnemyCity > 0) then 1586 begin 1587 for i := 0 to nContactBlock - 1 do 1588 PreparePlay(ContactBlock[i]); 1589 SoundPreloadDone := SoundPreloadDone or sbContact; 1590 end; 1591 if Check and sbTurn <> 0 then 1592 begin 1593 if MyRO.Happened and phShipComplete <> 0 then 1594 PreparePlay('MSG_YOUWIN'); 1595 if MyData.ToldAlive <> MyRO.Alive then 1596 PreparePlay('MSG_EXTINCT'); 1597 for cix := 0 to MyRO.nCity - 1 do 1598 with MyCity[cix] do 1599 if (Loc >= 0) and (Flags and CityRepMask <> 0) then 1600 for i := 0 to 12 do 1601 if 1 shl i and Flags and CityRepMask <> 0 then 1602 PreparePlay(CityEventSoundItem[i]); 1603 for mix := 0 to MyRO.nModel - 1 do 1604 with MyModel[mix] do 1605 if Attack > 0 then 1606 begin 1607 MakeModelInfo(me, mix, MyModel[mix], mi); 1608 PreparePlay(AttackSound(ModelCode(mi))); 1609 end 1610 end 1611 end; 1612 1613 procedure InitTurn(p: integer); 1614 const 1615 nAdvBookIcon = 16; 1616 AdvBookIcon: array [0 .. nAdvBookIcon - 1] of record Adv, 1617 Icon: integer end = ((Adv: adPolyTheism; Icon: woZeus), 1618 (Adv: adBronzeWorking; Icon: woColossus), (Adv: adMapMaking; 1619 Icon: woLighthouse), (Adv: adPoetry; Icon: imTheater), (Adv: adMonotheism; 1620 Icon: woMich), (Adv: adPhilosophy; Icon: woLeo), (Adv: adTheoryOfGravity; 1621 Icon: woNewton), (Adv: adSteel; Icon: woEiffel), (Adv: adDemocracy; 1622 Icon: woLiberty), (Adv: adAutomobile; Icon: imHighways), 1623 (Adv: adSanitation; Icon: imSewer), (Adv: adElectronics; Icon: woHoover), 1624 (Adv: adNuclearFission; Icon: woManhattan), (Adv: adRecycling; 1625 Icon: imRecycling), (Adv: adComputers; Icon: imResLab), 1626 (Adv: adSpaceFlight; Icon: woMIR)); 1627 var 1628 Domain, p1, i, ad, uix, cix, MoveOptions, MoveResult, Loc1, Dist, 1629 NewAgeCenterTo, Bankrupt, ShipMore, Winners, NewGovAvailable, dx, 1630 dy: integer; 1631 MoveAdviceData: TMoveAdviceData; 1632 Picture: TModelPictureInfo; 1633 s, Item, Item2: string; 1634 UpdatePanel, OwnWonder, ok, Stop, ShowCityList, WondersOnly, 1635 AllowCityScreen: boolean; 1636 begin 1637 if IsMultiPlayerGame and (p <> me) then 1638 begin 1639 UnitInfoBtn.Visible := false; 1640 UnitBtn.Visible := false; 1641 TerrainBtn.Visible := false; 1642 EOT.Visible := false; 1643 end; 1644 if IsMultiPlayerGame and (p <> me) and 1645 (G.RO[0].Happened and phShipComplete = 0) then 1646 begin // inter player screen 1647 for i := 0 to ControlCount - 1 do 1648 if Controls[i] is TButtonC then 1649 Controls[i].Visible := false; 1650 me := -1; 1651 SetMainTextureByAge(-1); 1652 with Panel.Canvas do 1653 begin 1654 Brush.Color := $000000; 1655 FillRect(Rect(0, 0, Panel.width, Panel.height)); 1656 Brush.Style := bsClear; 1657 end; 1658 with TopBar.Canvas do 1659 begin 1660 Brush.Color := $000000; 1661 FillRect(Rect(0, 0, TopBar.width, TopBar.height)); 1662 Brush.Style := bsClear; 1663 end; 1664 Invalidate; 1665 1666 s := TurnToString(G.RO[0].Turn); 1667 if supervising then 1668 SimpleMessage(Format(Phrases.Lookup('SUPERTURN'), [s])) 1669 else 1670 SimpleMessage(Format(Tribe[NewPlayer].TPhrase('TURN'), [s])); 1671 end; 1618 nAdvBookIcon = 16; 1619 AdvBookIcon: array [0 .. nAdvBookIcon - 1] of record Adv, 1620 Icon: integer end = ((Adv: adPolyTheism; Icon: woZeus), 1621 (Adv: adBronzeWorking; Icon: woColossus), (Adv: adMapMaking; 1622 Icon: woLighthouse), (Adv: adPoetry; Icon: imTheater), (Adv: adMonotheism; 1623 Icon: woMich), (Adv: adPhilosophy; Icon: woLeo), (Adv: adTheoryOfGravity; 1624 Icon: woNewton), (Adv: adSteel; Icon: woEiffel), (Adv: adDemocracy; 1625 Icon: woLiberty), (Adv: adAutomobile; Icon: imHighways), 1626 (Adv: adSanitation; Icon: imSewer), (Adv: adElectronics; Icon: woHoover), 1627 (Adv: adNuclearFission; Icon: woManhattan), (Adv: adRecycling; 1628 Icon: imRecycling), (Adv: adComputers; Icon: imResLab), 1629 (Adv: adSpaceFlight; Icon: woMIR)); 1630 var 1631 Domain, p1, i, ad, uix, cix, MoveOptions, MoveResult, Loc1, Dist, 1632 NewAgeCenterTo, Bankrupt, ShipMore, Winners, NewGovAvailable, dx, 1633 dy: integer; 1634 MoveAdviceData: TMoveAdviceData; 1635 Picture: TModelPictureInfo; 1636 s, Item, Item2: string; 1637 UpdatePanel, OwnWonder, ok, Stop, ShowCityList, WondersOnly, 1638 AllowCityScreen: boolean; 1639 begin 1640 if IsMultiPlayerGame and (NewPlayer <> me) then 1641 begin 1642 UnitInfoBtn.Visible := false; 1643 UnitBtn.Visible := false; 1644 TerrainBtn.Visible := false; 1645 EOT.Visible := false; 1646 end; 1647 if IsMultiPlayerGame and (NewPlayer <> me) and 1648 (G.RO[0].Happened and phShipComplete = 0) then 1649 begin // inter player screen 1672 1650 for i := 0 to ControlCount - 1 do 1673 1651 if Controls[i] is TButtonC then 1674 Controls[i].Visible := true; 1675 1676 ItsMeAgain(p); 1677 MyData := G.RO[p].Data; 1678 if not supervising then 1679 SoundPreload(sbAll); 1680 if (me = 0) and ((MyRO.Turn = 0) or (ClientMode = cResume)) then 1681 Invalidate; // colorize empty space 1682 1683 if not supervising then 1684 begin 1685 1686 { if MyRO.Happened and phGameEnd<>0 then 1687 begin 1688 Age:=3; 1689 SetMainTextureByAge(-1); 1652 Controls[i].Visible := false; 1653 me := -1; 1654 SetMainTextureByAge(-1); 1655 with Panel.Canvas do 1656 begin 1657 Brush.Color := $000000; 1658 FillRect(Rect(0, 0, Panel.width, Panel.height)); 1659 Brush.Style := bsClear; 1660 end; 1661 with TopBar.Canvas do 1662 begin 1663 Brush.Color := $000000; 1664 FillRect(Rect(0, 0, TopBar.width, TopBar.height)); 1665 Brush.Style := bsClear; 1666 end; 1667 Invalidate; 1668 1669 s := TurnToString(G.RO[0].Turn); 1670 if supervising then 1671 SimpleMessage(Format(Phrases.Lookup('SUPERTURN'), [s])) 1672 else 1673 SimpleMessage(Format(Tribe[NewPlayer].TPhrase('TURN'), [s])); 1674 end; 1675 for i := 0 to ControlCount - 1 do 1676 if Controls[i] is TButtonC then 1677 Controls[i].Visible := true; 1678 1679 ItsMeAgain(NewPlayer); 1680 MyData := G.RO[NewPlayer].Data; 1681 if not supervising then 1682 SoundPreload(sbAll); 1683 if (me = 0) and ((MyRO.Turn = 0) or (ClientMode = cResume)) then 1684 Invalidate; // colorize empty space 1685 1686 if not supervising then 1687 begin 1688 1689 { if MyRO.Happened and phGameEnd<>0 then 1690 begin 1691 Age:=3; 1692 SetMainTextureByAge(-1); 1693 end 1694 else } 1695 begin 1696 Age := GetAge(me); 1697 if SetMainTextureByAge(Age) then 1698 EOT.Invalidate; // has visible background parts in its bounds 1699 end; 1700 // age:=MyRO.Turn mod 4; //!!! 1701 if ClientMode = cMovieTurn then 1702 EOT.ButtonIndex := eotCancel 1703 else if ClientMode < scContact then 1704 EOT.ButtonIndex := eotGray 1705 else 1706 EOT.ButtonIndex := eotBackToNego; 1707 end 1708 else 1709 begin 1710 Age := 0; 1711 SetMainTextureByAge(-1); 1712 if ClientMode = cMovieTurn then 1713 EOT.ButtonIndex := eotCancel 1714 else 1715 EOT.ButtonIndex := eotBlinkOn; 1716 end; 1717 InitCityMark(MainTexture); 1718 CityDlg.CheckAge; 1719 NatStatDlg.CheckAge; 1720 UnitStatDlg.CheckAge; 1721 HelpDlg.Difficulty := G.Difficulty[me]; 1722 1723 UnFocus := -1; 1724 MarkCityLoc := -1; 1725 BlinkON := false; 1726 BlinkTime := -1; 1727 Tracking := false; 1728 TurnComplete := false; 1729 1730 if (ToldSlavery < 0) or 1731 ((ToldSlavery = 1) <> (MyRO.Wonder[woPyramids].EffectiveOwner >= 0)) then 1732 begin 1733 if MyRO.Wonder[woPyramids].EffectiveOwner >= 0 then 1734 ToldSlavery := 1 1735 else 1736 ToldSlavery := 0; 1737 for p1 := 0 to nPl - 1 do 1738 if (Tribe[p1] <> nil) and (Tribe[p1].mixSlaves >= 0) then 1739 with Picture do 1740 begin // replace unit picture 1741 mix := Tribe[p1].mixSlaves; 1742 if ToldSlavery = 1 then 1743 pix := pixSlaves 1744 else 1745 pix := pixNoSlaves; 1746 Hash := 0; 1747 GrName := 'StdUnits.png'; 1748 Tribe[p1].SetModelPicture(Picture, true); 1690 1749 end 1691 else } 1692 begin 1693 Age := GetAge(me); 1694 if SetMainTextureByAge(Age) then 1695 EOT.Invalidate; // has visible background parts in its bounds 1750 end; 1751 1752 if not supervising and (ClientMode = cTurn) then 1753 begin 1754 for cix := 0 to MyRO.nCity - 1 do 1755 if (MyCity[cix].Loc >= 0) and 1756 ((MyRO.Turn = 0) or (MyCity[cix].Flags and chFounded <> 0)) then 1757 MyCity[cix].Status := MyCity[cix].Status and 1758 not csResourceWeightsMask or (3 shl 4); 1759 // new city, set to maximum growth 1760 end; 1761 if (ClientMode = cTurn) or (ClientMode = cContinue) then 1762 CityOptimizer_BeginOfTurn; // maybe peace was made or has ended 1763 SumCities(TaxSum, ScienceSum); 1764 1765 if ClientMode = cMovieTurn then 1766 begin 1767 UnitInfoBtn.Visible := false; 1768 UnitBtn.Visible := false; 1769 TerrainBtn.Visible := false; 1770 EOT.Hint := Phrases.Lookup('BTN_STOP'); 1771 EOT.Visible := true; 1772 end 1773 else if ClientMode < scContact then 1774 begin 1775 UnitInfoBtn.Visible := UnFocus >= 0; 1776 UnitBtn.Visible := UnFocus >= 0; 1777 CheckTerrainBtnVisible; 1778 TurnComplete := supervising; 1779 EOT.Hint := Phrases.Lookup('BTN_ENDTURN'); 1780 EOT.Visible := Server(sTurn - sExecute, me, 0, nil^) >= rExecuted; 1781 end 1782 else 1783 begin 1784 UnitInfoBtn.Visible := false; 1785 UnitBtn.Visible := false; 1786 TerrainBtn.Visible := false; 1787 EOT.Hint := Phrases.Lookup('BTN_NEGO'); 1788 EOT.Visible := true; 1789 end; 1790 SetTroopLoc(-1); 1791 MapValid := false; 1792 NewAgeCenterTo := 0; 1793 if ((MyRO.Turn = 0) and not supervising or IsMultiPlayerGame or 1794 (ClientMode = cResume)) and (MyRO.nCity > 0) then 1795 begin 1796 Loc1 := MyCity[0].Loc; 1797 if (ClientMode = cTurn) and (MyRO.Turn = 0) then 1798 begin // move city out of center to not be covered by welcome screen 1799 dx := MapWidth div (xxt * 5); 1800 if dx > 5 then 1801 dx := 5; 1802 dy := MapHeight div (yyt * 5); 1803 if dy > 5 then 1804 dy := 5; 1805 if Loc1 >= G.lx * G.ly div 2 then 1806 begin 1807 NewAgeCenterTo := -1; 1808 Loc1 := dLoc(Loc1, -dx, -dy) 1809 end 1810 else 1811 begin 1812 NewAgeCenterTo := 1; 1813 Loc1 := dLoc(Loc1, -dx, dy); 1814 end 1815 end; 1816 Centre(Loc1) 1817 end; 1818 1819 for i := 0 to Screen.FormCount - 1 do 1820 if Screen.Forms[i] is TBufferedDrawDlg then 1821 Screen.Forms[i].Enabled := true; 1822 1823 if ClientMode <> cResume then 1824 begin 1825 PaintAll; 1826 if (MyRO.Happened and phChangeGov <> 0) and (MyRO.NatBuilt[imPalace] > 0) 1827 then 1828 ImpImage(Panel.Canvas, ClientWidth - xPalace, yPalace, imPalace, 1829 gAnarchy { , GameMode<>cMovie } ); 1830 // first turn after anarchy -- don't show despotism palace! 1831 Update; 1832 for i := 0 to Screen.FormCount - 1 do 1833 if (Screen.Forms[i].Visible) and (Screen.Forms[i] is TBufferedDrawDlg) 1834 then 1835 begin 1836 if @Screen.Forms[i].OnShow <> nil then 1837 Screen.Forms[i].OnShow(nil); 1838 Screen.Forms[i].Invalidate; 1839 Screen.Forms[i].Update; 1696 1840 end; 1697 // age:=MyRO.Turn mod 4; //!!! 1698 if ClientMode = cMovieTurn then 1699 EOT.ButtonIndex := eotCancel 1700 else if ClientMode < scContact then 1701 EOT.ButtonIndex := eotGray 1702 else 1703 EOT.ButtonIndex := eotBackToNego; 1704 end 1705 else 1706 begin 1707 Age := 0; 1708 SetMainTextureByAge(-1); 1709 if ClientMode = cMovieTurn then 1710 EOT.ButtonIndex := eotCancel 1711 else 1712 EOT.ButtonIndex := eotBlinkOn; 1713 end; 1714 InitCityMark(MainTexture); 1715 CityDlg.CheckAge; 1716 NatStatDlg.CheckAge; 1717 UnitStatDlg.CheckAge; 1718 HelpDlg.Difficulty := G.Difficulty[me]; 1719 1720 UnFocus := -1; 1721 MarkCityLoc := -1; 1722 BlinkON := false; 1723 BlinkTime := -1; 1724 Tracking := false; 1725 TurnComplete := false; 1726 1727 if (ToldSlavery < 0) or 1728 ((ToldSlavery = 1) <> (MyRO.Wonder[woPyramids].EffectiveOwner >= 0)) then 1729 begin 1730 if MyRO.Wonder[woPyramids].EffectiveOwner >= 0 then 1731 ToldSlavery := 1 1732 else 1733 ToldSlavery := 0; 1734 for p1 := 0 to nPl - 1 do 1735 if (Tribe[p1] <> nil) and (Tribe[p1].mixSlaves >= 0) then 1736 with Picture do 1737 begin // replace unit picture 1738 mix := Tribe[p1].mixSlaves; 1739 if ToldSlavery = 1 then 1740 pix := pixSlaves 1741 else 1742 pix := pixNoSlaves; 1743 Hash := 0; 1744 GrName := 'StdUnits.png'; 1745 Tribe[p1].SetModelPicture(Picture, true); 1841 1842 if MyRO.Happened and phGameEnd <> 0 then 1843 with MessgExDlg do 1844 begin // game ended 1845 if MyRO.Happened and phExtinct <> 0 then 1846 begin 1847 OpenSound := 'MSG_GAMEOVER'; 1848 MessgText := Tribe[me].TPhrase('GAMEOVER'); 1849 IconKind := mikBigIcon; 1850 IconIndex := 8; 1851 end 1852 else if MyRO.Happened and phShipComplete <> 0 then 1853 begin 1854 Winners := 0; 1855 for p1 := 0 to nPl - 1 do 1856 if 1 shl p1 and MyRO.Alive <> 0 then 1857 begin 1858 Winners := Winners or 1 shl p1; 1859 for i := 0 to nShipPart - 1 do 1860 if MyRO.Ship[p1].Parts[i] < ShipNeed[i] then 1861 Winners := Winners and not(1 shl p1); 1862 end; 1863 assert(Winners <> 0); 1864 if Winners and (1 shl me) <> 0 then 1865 begin 1866 s := ''; 1867 for p1 := 0 to nPl - 1 do 1868 if (p1 <> me) and (1 shl p1 and Winners <> 0) then 1869 if s = '' then 1870 s := Tribe[p1].TPhrase('SHORTNAME') 1871 else 1872 s := Format(Phrases.Lookup('SHAREDWIN_CONCAT'), 1873 [s, Tribe[p1].TPhrase('SHORTNAME')]); 1874 1875 OpenSound := 'MSG_YOUWIN'; 1876 MessgText := Tribe[me].TPhrase('MYSPACESHIP'); 1877 if s <> '' then 1878 MessgText := MessgText + '\' + 1879 Format(Phrases.Lookup('SHAREDWIN'), [s]); 1880 IconKind := mikBigIcon; 1881 IconIndex := 9; 1746 1882 end 1747 end; 1748 1749 if not supervising and (ClientMode = cTurn) then 1750 begin 1751 for cix := 0 to MyRO.nCity - 1 do 1752 if (MyCity[cix].Loc >= 0) and 1753 ((MyRO.Turn = 0) or (MyCity[cix].Flags and chFounded <> 0)) then 1754 MyCity[cix].Status := MyCity[cix].Status and 1755 not csResourceWeightsMask or (3 shl 4); 1756 // new city, set to maximum growth 1757 end; 1758 if (ClientMode = cTurn) or (ClientMode = cContinue) then 1759 CityOptimizer_BeginOfTurn; // maybe peace was made or has ended 1760 SumCities(TaxSum, ScienceSum); 1761 1762 if ClientMode = cMovieTurn then 1763 begin 1764 UnitInfoBtn.Visible := false; 1765 UnitBtn.Visible := false; 1766 TerrainBtn.Visible := false; 1767 EOT.Hint := Phrases.Lookup('BTN_STOP'); 1768 EOT.Visible := true; 1769 end 1770 else if ClientMode < scContact then 1771 begin 1772 UnitInfoBtn.Visible := UnFocus >= 0; 1773 UnitBtn.Visible := UnFocus >= 0; 1774 CheckTerrainBtnVisible; 1775 TurnComplete := supervising; 1776 EOT.Hint := Phrases.Lookup('BTN_ENDTURN'); 1777 EOT.Visible := Server(sTurn - sExecute, me, 0, nil^) >= rExecuted; 1778 end 1779 else 1780 begin 1781 UnitInfoBtn.Visible := false; 1782 UnitBtn.Visible := false; 1783 TerrainBtn.Visible := false; 1784 EOT.Hint := Phrases.Lookup('BTN_NEGO'); 1785 EOT.Visible := true; 1786 end; 1787 SetTroopLoc(-1); 1788 MapValid := false; 1789 NewAgeCenterTo := 0; 1790 if ((MyRO.Turn = 0) and not supervising or IsMultiPlayerGame or 1791 (ClientMode = cResume)) and (MyRO.nCity > 0) then 1792 begin 1793 Loc1 := MyCity[0].Loc; 1794 if (ClientMode = cTurn) and (MyRO.Turn = 0) then 1795 begin // move city out of center to not be covered by welcome screen 1796 dx := MapWidth div (xxt * 5); 1797 if dx > 5 then 1798 dx := 5; 1799 dy := MapHeight div (yyt * 5); 1800 if dy > 5 then 1801 dy := 5; 1802 if Loc1 >= G.lx * G.ly div 2 then 1803 begin 1804 NewAgeCenterTo := -1; 1805 Loc1 := dLoc(Loc1, -dx, -dy) 1806 end 1807 else 1808 begin 1809 NewAgeCenterTo := 1; 1810 Loc1 := dLoc(Loc1, -dx, dy); 1811 end 1812 end; 1813 Centre(Loc1) 1814 end; 1815 1816 for i := 0 to Screen.FormCount - 1 do 1817 if Screen.Forms[i] is TBufferedDrawDlg then 1818 Screen.Forms[i].Enabled := true; 1819 1820 if ClientMode <> cResume then 1821 begin 1822 PaintAll; 1823 if (MyRO.Happened and phChangeGov <> 0) and (MyRO.NatBuilt[imPalace] > 0) 1824 then 1825 ImpImage(Panel.Canvas, ClientWidth - xPalace, yPalace, imPalace, 1826 gAnarchy { , GameMode<>cMovie } ); 1827 // first turn after anarchy -- don't show despotism palace! 1828 Update; 1829 for i := 0 to Screen.FormCount - 1 do 1830 if (Screen.Forms[i].Visible) and (Screen.Forms[i] is TBufferedDrawDlg) 1831 then 1832 begin 1833 if @Screen.Forms[i].OnShow <> nil then 1834 Screen.Forms[i].OnShow(nil); 1835 Screen.Forms[i].Invalidate; 1836 Screen.Forms[i].Update; 1837 end; 1838 1839 if MyRO.Happened and phGameEnd <> 0 then 1840 with MessgExDlg do 1841 begin // game ended 1842 if MyRO.Happened and phExtinct <> 0 then 1843 begin 1844 OpenSound := 'MSG_GAMEOVER'; 1845 MessgText := Tribe[me].TPhrase('GAMEOVER'); 1846 IconKind := mikBigIcon; 1847 IconIndex := 8; 1848 end 1849 else if MyRO.Happened and phShipComplete <> 0 then 1850 begin 1851 Winners := 0; 1852 for p1 := 0 to nPl - 1 do 1853 if 1 shl p1 and MyRO.Alive <> 0 then 1854 begin 1855 Winners := Winners or 1 shl p1; 1856 for i := 0 to nShipPart - 1 do 1857 if MyRO.Ship[p1].Parts[i] < ShipNeed[i] then 1858 Winners := Winners and not(1 shl p1); 1859 end; 1860 assert(Winners <> 0); 1861 if Winners and (1 shl me) <> 0 then 1862 begin 1863 s := ''; 1864 for p1 := 0 to nPl - 1 do 1865 if (p1 <> me) and (1 shl p1 and Winners <> 0) then 1866 if s = '' then 1867 s := Tribe[p1].TPhrase('SHORTNAME') 1868 else 1869 s := Format(Phrases.Lookup('SHAREDWIN_CONCAT'), 1870 [s, Tribe[p1].TPhrase('SHORTNAME')]); 1871 1872 OpenSound := 'MSG_YOUWIN'; 1873 MessgText := Tribe[me].TPhrase('MYSPACESHIP'); 1874 if s <> '' then 1875 MessgText := MessgText + '\' + 1876 Format(Phrases.Lookup('SHAREDWIN'), [s]); 1877 IconKind := mikBigIcon; 1878 IconIndex := 9; 1879 end 1880 else 1881 begin 1882 assert(me = 0); 1883 OpenSound := 'MSG_GAMEOVER'; 1884 MessgText := ''; 1885 for p1 := 0 to nPl - 1 do 1886 if Winners and (1 shl p1) <> 0 then 1887 MessgText := MessgText + Tribe[p1].TPhrase('SPACESHIP1'); 1888 MessgText := MessgText + '\' + Phrases.Lookup('SPACESHIP2'); 1889 IconKind := mikEnemyShipComplete; 1890 end 1891 end 1892 else { if MyRO.Happened and fTimeUp<>0 then } 1883 else 1893 1884 begin 1894 1885 assert(me = 0); 1895 1886 OpenSound := 'MSG_GAMEOVER'; 1896 if not supervising then 1897 MessgText := Tribe[me].TPhrase('TIMEUP') 1898 else 1899 MessgText := Phrases.Lookup('TIMEUPSUPER'); 1900 IconKind := mikImp; 1901 IconIndex := 22; 1902 end; 1903 Kind := mkOk; 1904 ShowModal; 1905 if MyRO.Happened and phExtinct = 0 then 1906 begin 1907 p1 := 0; 1908 while (p1 < nPl - 1) and (Winners and (1 shl p1) = 0) do 1909 inc(p1); 1910 if MyRO.Happened and phShipComplete = 0 then 1911 DiaDlg.ShowNewContent_Charts(wmModal); 1912 end; 1913 TurnComplete := true; 1914 exit; 1887 MessgText := ''; 1888 for p1 := 0 to nPl - 1 do 1889 if Winners and (1 shl p1) <> 0 then 1890 MessgText := MessgText + Tribe[p1].TPhrase('SPACESHIP1'); 1891 MessgText := MessgText + '\' + Phrases.Lookup('SPACESHIP2'); 1892 IconKind := mikEnemyShipComplete; 1893 end 1894 end 1895 else { if MyRO.Happened and fTimeUp<>0 then } 1896 begin 1897 assert(me = 0); 1898 OpenSound := 'MSG_GAMEOVER'; 1899 if not supervising then 1900 MessgText := Tribe[me].TPhrase('TIMEUP') 1901 else 1902 MessgText := Phrases.Lookup('TIMEUPSUPER'); 1903 IconKind := mikImp; 1904 IconIndex := 22; 1915 1905 end; 1916 if not supervising and (1 shl me and MyRO.Alive = 0) then 1917 begin 1906 Kind := mkOk; 1907 ShowModal; 1908 if MyRO.Happened and phExtinct = 0 then 1909 begin 1910 p1 := 0; 1911 while (p1 < nPl - 1) and (Winners and (1 shl p1) = 0) do 1912 inc(p1); 1913 if MyRO.Happened and phShipComplete = 0 then 1914 DiaDlg.ShowNewContent_Charts(wmModal); 1915 end; 1918 1916 TurnComplete := true; 1919 1917 exit; 1920 1918 end; 1921 1922 if (ClientMode = cContinue) and 1923 (DipMem[me].SentCommand and $FF0F = scContact) then 1924 // contact was refused 1925 if MyRO.Treaty[DipMem[me].pContact] >= trPeace then 1926 ContactRefused(DipMem[me].pContact, 'FRREJECTED') 1927 else 1928 SoundMessage(Tribe[DipMem[me].pContact].TPhrase('FRREJECTED'), 1929 'NEGO_REJECTED'); 1930 1931 if not supervising and (Age > MyData.ToldAge) and 1932 ((Age > 0) or (ClientMode <> cMovieTurn)) then 1933 with MessgExDlg do 1934 begin 1935 if Age = 0 then 1919 if not supervising and (1 shl me and MyRO.Alive = 0) then 1920 begin 1921 TurnComplete := true; 1922 exit; 1923 end; 1924 1925 if (ClientMode = cContinue) and 1926 (DipMem[me].SentCommand and $FF0F = scContact) then 1927 // contact was refused 1928 if MyRO.Treaty[DipMem[me].pContact] >= trPeace then 1929 ContactRefused(DipMem[me].pContact, 'FRREJECTED') 1930 else 1931 SoundMessage(Tribe[DipMem[me].pContact].TPhrase('FRREJECTED'), 1932 'NEGO_REJECTED'); 1933 1934 if not supervising and (Age > MyData.ToldAge) and 1935 ((Age > 0) or (ClientMode <> cMovieTurn)) then 1936 with MessgExDlg do 1937 begin 1938 if Age = 0 then 1939 begin 1940 if Phrases2FallenBackToEnglish then 1936 1941 begin 1937 if Phrases2FallenBackToEnglish then 1938 begin 1939 s := Tribe[me].TPhrase('AGE0'); 1940 MessgText := 1941 Format(s, [TurnToString(MyRO.Turn), CityName(MyCity[0].ID)]) 1942 end 1943 else 1944 begin 1945 s := Tribe[me].TString(Phrases2.Lookup('AGE0')); 1946 MessgText := Format(s, [TurnToString(MyRO.Turn)]); 1947 end 1942 s := Tribe[me].TPhrase('AGE0'); 1943 MessgText := 1944 Format(s, [TurnToString(MyRO.Turn), CityName(MyCity[0].ID)]) 1948 1945 end 1949 1946 else 1950 1947 begin 1951 s := Tribe[me].T Phrase('AGE' + char(48 + Age));1948 s := Tribe[me].TString(Phrases2.Lookup('AGE0')); 1952 1949 MessgText := Format(s, [TurnToString(MyRO.Turn)]); 1953 end;1954 IconKind := mikAge;1955 IconIndex := Age;1956 { if age=0 then } Kind := mkOk1957 { else begin Kind:=mkOkHelp; HelpKind:=hkAdv; HelpNo:=AgePreq[age]; end };1958 CenterTo := NewAgeCenterTo;1959 OpenSound := 'AGE_' + char(48 + Age);1960 ShowModal;1961 MyData.ToldAge := Age;1962 if Age > 0 then1963 MyData.ToldTech[AgePreq[Age]] := MyRO.Tech[AgePreq[Age]];1964 end;1965 1966 if MyData.ToldAlive <> MyRO.Alive then1967 begin1968 for p1 := 0 to nPl - 1 do1969 if (MyData.ToldAlive - MyRO.Alive) and (1 shl p1) <> 0 then1970 with MessgExDlg do1971 begin1972 OpenSound := 'MSG_EXTINCT';1973 s := Tribe[p1].TPhrase('EXTINCT');1974 MessgText := Format(s, [TurnToString(MyRO.Turn)]);1975 if MyRO.Alive = 1 shl me then1976 MessgText := MessgText + Phrases.Lookup('EXTINCTALL');1977 Kind := mkOk;1978 IconKind := mikImp;1979 IconIndex := 21;1980 ShowModal;1981 end;1982 if (ClientMode <> cMovieTurn) and not supervising then1983 DiaDlg.ShowNewContent_Charts(wmModal);1984 end;1985 1986 // tell changes of own credibility1987 if not supervising then1988 begin1989 if RoughCredibility(MyRO.Credibility) <>1990 RoughCredibility(MyData.ToldOwnCredibility) then1991 begin1992 if RoughCredibility(MyRO.Credibility) >1993 RoughCredibility(MyData.ToldOwnCredibility) then1994 s := Phrases.Lookup('CREDUP')1995 else1996 s := Phrases.Lookup('CREDDOWN');1997 TribeMessage(me, Format(s, [Phrases.Lookup('CREDIBILITY',1998 RoughCredibility(MyRO.Credibility))]), '');1999 end;2000 MyData.ToldOwnCredibility := MyRO.Credibility;2001 end;2002 2003 for i := 0 to 27 do2004 begin2005 OwnWonder := false;2006 for cix := 0 to MyRO.nCity - 1 do2007 if (MyCity[cix].Loc >= 0) and (MyCity[cix].ID = MyRO.Wonder[i].CityID)2008 then2009 OwnWonder := true;2010 if MyRO.Wonder[i].CityID <> MyData.ToldWonders[i].CityID then2011 begin2012 if MyRO.Wonder[i].CityID = -2 then2013 with MessgExDlg do2014 begin { tell about destroyed wonders }2015 OpenSound := 'WONDER_DESTROYED';2016 MessgText := Format(Phrases.Lookup('WONDERDEST'),2017 [Phrases.Lookup('IMPROVEMENTS', i)]);2018 Kind := mkOkHelp;2019 HelpKind := hkImp;2020 HelpNo := i;2021 IconKind := mikImp;2022 IconIndex := i;2023 ShowModal;2024 end2025 else2026 begin2027 if i = woManhattan then2028 if MyRO.Wonder[i].EffectiveOwner > me then2029 MyData.ColdWarStart := MyRO.Turn - 12030 else2031 MyData.ColdWarStart := MyRO.Turn;2032 if not OwnWonder then2033 with MessgExDlg do2034 begin { tell about newly built wonders }2035 if i = woManhattan then2036 begin2037 OpenSound := 'MSG_COLDWAR';2038 s := Tribe[MyRO.Wonder[i].EffectiveOwner].TPhrase('COLDWAR')2039 end2040 else if MyRO.Wonder[i].EffectiveOwner >= 0 then2041 begin2042 OpenSound := 'WONDER_BUILT';2043 s := Tribe[MyRO.Wonder[i].EffectiveOwner]2044 .TPhrase('WONDERBUILT')2045 end2046 else2047 begin2048 OpenSound := 'MSG_DEFAULT';2049 s := Phrases.Lookup('WONDERBUILTEXP');2050 // already expired when built2051 end;2052 MessgText := Format(s, [Phrases.Lookup('IMPROVEMENTS', i),2053 CityName(MyRO.Wonder[i].CityID)]);2054 Kind := mkOkHelp;2055 HelpKind := hkImp;2056 HelpNo := i;2057 IconKind := mikImp;2058 IconIndex := i;2059 ShowModal;2060 end2061 1950 end 2062 1951 end 2063 else if (MyRO.Wonder[i].EffectiveOwner <> MyData.ToldWonders[i] 2064 .EffectiveOwner) and (MyRO.Wonder[i].CityID > -2) then 2065 if MyRO.Wonder[i].EffectiveOwner < 0 then 1952 else 1953 begin 1954 s := Tribe[me].TPhrase('AGE' + char(48 + Age)); 1955 MessgText := Format(s, [TurnToString(MyRO.Turn)]); 1956 end; 1957 IconKind := mikAge; 1958 IconIndex := Age; 1959 { if age=0 then } Kind := mkOk 1960 { else begin Kind:=mkOkHelp; HelpKind:=hkAdv; HelpNo:=AgePreq[age]; end }; 1961 CenterTo := NewAgeCenterTo; 1962 OpenSound := 'AGE_' + char(48 + Age); 1963 ShowModal; 1964 MyData.ToldAge := Age; 1965 if Age > 0 then 1966 MyData.ToldTech[AgePreq[Age]] := MyRO.Tech[AgePreq[Age]]; 1967 end; 1968 1969 if MyData.ToldAlive <> MyRO.Alive then 1970 begin 1971 for p1 := 0 to nPl - 1 do 1972 if (MyData.ToldAlive - MyRO.Alive) and (1 shl p1) <> 0 then 1973 with MessgExDlg do 2066 1974 begin 2067 if i <> woMIR then 2068 with MessgExDlg do 2069 begin { tell about expired wonders } 2070 OpenSound := 'WONDER_EXPIRED'; 2071 MessgText := Format(Phrases.Lookup('WONDEREXP'), 2072 [Phrases.Lookup('IMPROVEMENTS', i), 2073 CityName(MyRO.Wonder[i].CityID)]); 2074 Kind := mkOkHelp; 2075 HelpKind := hkImp; 2076 HelpNo := i; 2077 IconKind := mikImp; 2078 IconIndex := i; 2079 ShowModal; 1975 OpenSound := 'MSG_EXTINCT'; 1976 s := Tribe[p1].TPhrase('EXTINCT'); 1977 MessgText := Format(s, [TurnToString(MyRO.Turn)]); 1978 if MyRO.Alive = 1 shl me then 1979 MessgText := MessgText + Phrases.Lookup('EXTINCTALL'); 1980 Kind := mkOk; 1981 IconKind := mikImp; 1982 IconIndex := 21; 1983 ShowModal; 1984 end; 1985 if (ClientMode <> cMovieTurn) and not supervising then 1986 DiaDlg.ShowNewContent_Charts(wmModal); 1987 end; 1988 1989 // tell changes of own credibility 1990 if not supervising then 1991 begin 1992 if RoughCredibility(MyRO.Credibility) <> 1993 RoughCredibility(MyData.ToldOwnCredibility) then 1994 begin 1995 if RoughCredibility(MyRO.Credibility) > 1996 RoughCredibility(MyData.ToldOwnCredibility) then 1997 s := Phrases.Lookup('CREDUP') 1998 else 1999 s := Phrases.Lookup('CREDDOWN'); 2000 TribeMessage(me, Format(s, [Phrases.Lookup('CREDIBILITY', 2001 RoughCredibility(MyRO.Credibility))]), ''); 2002 end; 2003 MyData.ToldOwnCredibility := MyRO.Credibility; 2004 end; 2005 2006 for i := 0 to 27 do 2007 begin 2008 OwnWonder := false; 2009 for cix := 0 to MyRO.nCity - 1 do 2010 if (MyCity[cix].Loc >= 0) and (MyCity[cix].ID = MyRO.Wonder[i].CityID) 2011 then 2012 OwnWonder := true; 2013 if MyRO.Wonder[i].CityID <> MyData.ToldWonders[i].CityID then 2014 begin 2015 if MyRO.Wonder[i].CityID = -2 then 2016 with MessgExDlg do 2017 begin { tell about destroyed wonders } 2018 OpenSound := 'WONDER_DESTROYED'; 2019 MessgText := Format(Phrases.Lookup('WONDERDEST'), 2020 [Phrases.Lookup('IMPROVEMENTS', i)]); 2021 Kind := mkOkHelp; 2022 HelpKind := hkImp; 2023 HelpNo := i; 2024 IconKind := mikImp; 2025 IconIndex := i; 2026 ShowModal; 2027 end 2028 else 2029 begin 2030 if i = woManhattan then 2031 if MyRO.Wonder[i].EffectiveOwner > me then 2032 MyData.ColdWarStart := MyRO.Turn - 1 2033 else 2034 MyData.ColdWarStart := MyRO.Turn; 2035 if not OwnWonder then 2036 with MessgExDlg do 2037 begin { tell about newly built wonders } 2038 if i = woManhattan then 2039 begin 2040 OpenSound := 'MSG_COLDWAR'; 2041 s := Tribe[MyRO.Wonder[i].EffectiveOwner].TPhrase('COLDWAR') 2080 2042 end 2081 end 2082 else if (MyData.ToldWonders[i].EffectiveOwner >= 0) and not OwnWonder 2083 then 2084 with MessgExDlg do 2085 begin { tell about capture of wonders } 2086 OpenSound := 'WONDER_CAPTURED'; 2087 s := Tribe[MyRO.Wonder[i].EffectiveOwner].TPhrase('WONDERCAPT'); 2043 else if MyRO.Wonder[i].EffectiveOwner >= 0 then 2044 begin 2045 OpenSound := 'WONDER_BUILT'; 2046 s := Tribe[MyRO.Wonder[i].EffectiveOwner] 2047 .TPhrase('WONDERBUILT') 2048 end 2049 else 2050 begin 2051 OpenSound := 'MSG_DEFAULT'; 2052 s := Phrases.Lookup('WONDERBUILTEXP'); 2053 // already expired when built 2054 end; 2088 2055 MessgText := Format(s, [Phrases.Lookup('IMPROVEMENTS', i), 2089 2056 CityName(MyRO.Wonder[i].CityID)]); … … 2094 2061 IconIndex := i; 2095 2062 ShowModal; 2096 end; 2097 end; 2098 2099 if MyRO.Turn = MyData.ColdWarStart + ColdWarTurns then 2100 begin 2101 SoundMessageEx(Phrases.Lookup('COLDWAREND'), 'MSG_DEFAULT'); 2102 MyData.ColdWarStart := -ColdWarTurns - 1 2103 end; 2104 2105 TellNewModels; 2106 end; // ClientMode<>cResume 2107 MyData.ToldAlive := MyRO.Alive; 2108 move(MyRO.Wonder, MyData.ToldWonders, SizeOf(MyData.ToldWonders)); 2109 2110 NewGovAvailable := -1; 2111 if ClientMode <> cResume then 2112 begin // tell about new techs 2113 for ad := 0 to nAdv - 1 do 2114 if (MyRO.TestFlags and tfAllTechs = 0) and 2115 ((MyRO.Tech[ad] >= tsApplicable) <> (MyData.ToldTech[ad] >= 2116 tsApplicable)) or (ad in FutureTech) and 2117 (MyRO.Tech[ad] <> MyData.ToldTech[ad]) then 2063 end 2064 end 2065 end 2066 else if (MyRO.Wonder[i].EffectiveOwner <> MyData.ToldWonders[i] 2067 .EffectiveOwner) and (MyRO.Wonder[i].CityID > -2) then 2068 if MyRO.Wonder[i].EffectiveOwner < 0 then 2069 begin 2070 if i <> woMIR then 2071 with MessgExDlg do 2072 begin { tell about expired wonders } 2073 OpenSound := 'WONDER_EXPIRED'; 2074 MessgText := Format(Phrases.Lookup('WONDEREXP'), 2075 [Phrases.Lookup('IMPROVEMENTS', i), 2076 CityName(MyRO.Wonder[i].CityID)]); 2077 Kind := mkOkHelp; 2078 HelpKind := hkImp; 2079 HelpNo := i; 2080 IconKind := mikImp; 2081 IconIndex := i; 2082 ShowModal; 2083 end 2084 end 2085 else if (MyData.ToldWonders[i].EffectiveOwner >= 0) and not OwnWonder 2086 then 2118 2087 with MessgExDlg do 2119 begin 2120 Item := 'RESEARCH_GENERAL'; 2121 if GameMode <> cMovie then 2122 OpenSound := 'NEWADVANCE_' + char(48 + Age); 2123 Item2 := Phrases.Lookup('ADVANCES', ad); 2124 if ad in FutureTech then 2125 Item2 := Item2 + ' ' + IntToStr(MyRO.Tech[ad]); 2126 MessgText := Format(Phrases.Lookup(Item), [Item2]); 2088 begin { tell about capture of wonders } 2089 OpenSound := 'WONDER_CAPTURED'; 2090 s := Tribe[MyRO.Wonder[i].EffectiveOwner].TPhrase('WONDERCAPT'); 2091 MessgText := Format(s, [Phrases.Lookup('IMPROVEMENTS', i), 2092 CityName(MyRO.Wonder[i].CityID)]); 2127 2093 Kind := mkOkHelp; 2128 HelpKind := hkAdv; 2129 HelpNo := ad; 2130 IconKind := mikBook; 2131 IconIndex := -1; 2132 for i := 0 to nAdvBookIcon - 1 do 2133 if AdvBookIcon[i].Adv = ad then 2134 IconIndex := AdvBookIcon[i].Icon; 2094 HelpKind := hkImp; 2095 HelpNo := i; 2096 IconKind := mikImp; 2097 IconIndex := i; 2135 2098 ShowModal; 2136 MyData.ToldTech[ad] := MyRO.Tech[ad];2137 for i := gMonarchy to nGov - 1 do2138 if GovPreq[i] = ad then2139 NewGovAvailable := i;2140 2099 end; 2141 2100 end; 2142 2101 2143 ShowCityList := false; 2144 if ClientMode = cTurn then 2145 begin 2146 if (MyRO.Happened and phTech <> 0) and (MyData.FarTech <> adNexus) then 2147 ChooseResearch; 2148 2149 UpdatePanel := false; 2150 if MyRO.Happened and phChangeGov <> 0 then 2151 begin 2152 ModalSelectDlg.ShowNewContent(wmModal, kGov); 2153 Play('NEWGOV'); 2154 Server(sSetGovernment, me, ModalSelectDlg.result, nil^); 2155 CityOptimizer_BeginOfTurn; 2156 UpdatePanel := true; 2157 end; 2158 end; // ClientMode=cTurn 2159 2160 if not supervising and ((ClientMode = cTurn) or (ClientMode = cMovieTurn)) 2161 then 2102 if MyRO.Turn = MyData.ColdWarStart + ColdWarTurns then 2103 begin 2104 SoundMessageEx(Phrases.Lookup('COLDWAREND'), 'MSG_DEFAULT'); 2105 MyData.ColdWarStart := -ColdWarTurns - 1 2106 end; 2107 2108 TellNewModels; 2109 end; // ClientMode<>cResume 2110 MyData.ToldAlive := MyRO.Alive; 2111 move(MyRO.Wonder, MyData.ToldWonders, SizeOf(MyData.ToldWonders)); 2112 2113 NewGovAvailable := -1; 2114 if ClientMode <> cResume then 2115 begin // tell about new techs 2116 for ad := 0 to nAdv - 1 do 2117 if (MyRO.TestFlags and tfAllTechs = 0) and 2118 ((MyRO.Tech[ad] >= tsApplicable) <> (MyData.ToldTech[ad] >= 2119 tsApplicable)) or (ad in FutureTech) and 2120 (MyRO.Tech[ad] <> MyData.ToldTech[ad]) then 2121 with MessgExDlg do 2122 begin 2123 Item := 'RESEARCH_GENERAL'; 2124 if GameMode <> cMovie then 2125 OpenSound := 'NEWADVANCE_' + char(48 + Age); 2126 Item2 := Phrases.Lookup('ADVANCES', ad); 2127 if ad in FutureTech then 2128 Item2 := Item2 + ' ' + IntToStr(MyRO.Tech[ad]); 2129 MessgText := Format(Phrases.Lookup(Item), [Item2]); 2130 Kind := mkOkHelp; 2131 HelpKind := hkAdv; 2132 HelpNo := ad; 2133 IconKind := mikBook; 2134 IconIndex := -1; 2135 for i := 0 to nAdvBookIcon - 1 do 2136 if AdvBookIcon[i].Adv = ad then 2137 IconIndex := AdvBookIcon[i].Icon; 2138 ShowModal; 2139 MyData.ToldTech[ad] := MyRO.Tech[ad]; 2140 for i := gMonarchy to nGov - 1 do 2141 if GovPreq[i] = ad then 2142 NewGovAvailable := i; 2143 end; 2144 end; 2145 2146 ShowCityList := false; 2147 if ClientMode = cTurn then 2148 begin 2149 if (MyRO.Happened and phTech <> 0) and (MyData.FarTech <> adNexus) then 2150 ChooseResearch; 2151 2152 UpdatePanel := false; 2153 if MyRO.Happened and phChangeGov <> 0 then 2154 begin 2155 ModalSelectDlg.ShowNewContent(wmModal, kGov); 2156 Play('NEWGOV'); 2157 Server(sSetGovernment, me, ModalSelectDlg.result, nil^); 2158 CityOptimizer_BeginOfTurn; 2159 UpdatePanel := true; 2160 end; 2161 end; // ClientMode=cTurn 2162 2163 if not supervising and ((ClientMode = cTurn) or (ClientMode = cMovieTurn)) 2164 then 2165 for cix := 0 to MyRO.nCity - 1 do 2166 with MyCity[cix] do 2167 Status := Status and not csToldBombard; 2168 2169 if ((ClientMode = cTurn) or (ClientMode = cMovieTurn)) and 2170 (MyRO.Government <> gAnarchy) then 2171 begin 2172 // tell what happened in cities 2173 for WondersOnly := true downto false do 2162 2174 for cix := 0 to MyRO.nCity - 1 do 2163 2175 with MyCity[cix] do 2164 Status := Status and not csToldBombard; 2165 2166 if ((ClientMode = cTurn) or (ClientMode = cMovieTurn)) and 2167 (MyRO.Government <> gAnarchy) then 2168 begin 2169 // tell what happened in cities 2170 for WondersOnly := true downto false do 2171 for cix := 0 to MyRO.nCity - 1 do 2172 with MyCity[cix] do 2173 if (MyRO.Turn > 0) and (Loc >= 0) and (Flags and chCaptured = 0) and 2174 (WondersOnly = (Flags and chProduction <> 0) and 2175 (Project0 and cpImp <> 0) and (Project0 and cpIndex < 28)) then 2176 if (MyRO.Turn > 0) and (Loc >= 0) and (Flags and chCaptured = 0) and 2177 (WondersOnly = (Flags and chProduction <> 0) and 2178 (Project0 and cpImp <> 0) and (Project0 and cpIndex < 28)) then 2179 begin 2180 if WondersOnly then 2181 with MessgExDlg do 2182 begin { tell about newly built wonder } 2183 OpenSound := 'WONDER_BUILT'; 2184 s := Tribe[me].TPhrase('WONDERBUILTOWN'); 2185 MessgText := 2186 Format(s, [Phrases.Lookup('IMPROVEMENTS', 2187 Project0 and cpIndex), CityName(ID)]); 2188 Kind := mkOkHelp; 2189 HelpKind := hkImp; 2190 HelpNo := Project0 and cpIndex; 2191 IconKind := mikImp; 2192 IconIndex := Project0 and cpIndex; 2193 ShowModal; 2194 end; 2195 if not supervising and (ClientMode = cTurn) then 2176 2196 begin 2177 if WondersOnly then 2178 with MessgExDlg do 2179 begin { tell about newly built wonder } 2180 OpenSound := 'WONDER_BUILT'; 2181 s := Tribe[me].TPhrase('WONDERBUILTOWN'); 2182 MessgText := 2183 Format(s, [Phrases.Lookup('IMPROVEMENTS', 2184 Project0 and cpIndex), CityName(ID)]); 2185 Kind := mkOkHelp; 2186 HelpKind := hkImp; 2187 HelpNo := Project0 and cpIndex; 2188 IconKind := mikImp; 2189 IconIndex := Project0 and cpIndex; 2190 ShowModal; 2191 end; 2192 if not supervising and (ClientMode = cTurn) then 2197 AllowCityScreen := true; 2198 if (Status and 7 <> 0) and 2199 (Project and (cpImp + cpIndex) = cpImp + imTrGoods) then 2200 if (MyData.ImpOrder[Status and 7 - 1, 0] >= 0) then 2201 begin 2202 if AutoBuild(cix, MyData.ImpOrder[Status and 7 - 1]) then 2203 AllowCityScreen := false 2204 else if Flags and chProduction <> 0 then 2205 Flags := (Flags and not chProduction) or chAllImpsMade 2206 end 2207 else 2208 Flags := Flags or chTypeDel; 2209 if (Size >= NeedAqueductSize) and 2210 (MyRO.Tech[Imp[imAqueduct].Preq] < tsApplicable) or 2211 (Size >= NeedSewerSize) and 2212 (MyRO.Tech[Imp[imSewer].Preq] < tsApplicable) then 2213 Flags := Flags and not chNoGrowthWarning; 2214 // don't remind of unknown building 2215 if Flags and chNoSettlerProd = 0 then 2216 Status := Status and not csToldDelay 2217 else if Status and csToldDelay = 0 then 2218 Status := Status or csToldDelay 2219 else 2220 Flags := Flags and not chNoSettlerProd; 2221 if mRepScreens.Checked then 2193 2222 begin 2194 AllowCityScreen := true; 2195 if (Status and 7 <> 0) and 2196 (Project and (cpImp + cpIndex) = cpImp + imTrGoods) then 2197 if (MyData.ImpOrder[Status and 7 - 1, 0] >= 0) then 2223 if (Flags and CityRepMask <> 0) and AllowCityScreen then 2224 begin { show what happened in cities } 2225 SetTroopLoc(MyCity[cix].Loc); 2226 MarkCityLoc := MyCity[cix].Loc; 2227 PanelPaint; 2228 CityDlg.CloseAction := None; 2229 CityDlg.ShowNewContent(wmModal, MyCity[cix].Loc, 2230 Flags and CityRepMask); 2231 UpdatePanel := true; 2232 end 2233 end 2234 else { if mRepList.Checked then } 2235 begin 2236 if Flags and CityRepMask <> 0 then 2237 ShowCityList := true 2238 end 2239 end 2240 end; { city loop } 2241 end; // ClientMode=cTurn 2242 2243 if ClientMode = cTurn then 2244 begin 2245 if NewGovAvailable >= 0 then 2246 with MessgExDlg do 2247 begin 2248 MessgText := Format(Phrases.Lookup('AUTOREVOLUTION'), 2249 [Phrases.Lookup('GOVERNMENT', NewGovAvailable)]); 2250 Kind := mkYesNo; 2251 IconKind := mikPureIcon; 2252 IconIndex := 6 + NewGovAvailable; 2253 ShowModal; 2254 if ModalResult = mrOK then 2255 begin 2256 Play('REVOLUTION'); 2257 Server(sRevolution, me, 0, nil^); 2258 end 2259 end; 2260 end; // ClientMode=cTurn 2261 2262 if (ClientMode = cTurn) or (ClientMode = cMovieTurn) then 2263 begin 2264 if MyRO.Happened and phGliderLost <> 0 then 2265 ContextMessage(Phrases.Lookup('GLIDERLOST'), 'MSG_DEFAULT', 2266 hkModel, 200); 2267 if MyRO.Happened and phPlaneLost <> 0 then 2268 ContextMessage(Phrases.Lookup('PLANELOST'), 'MSG_DEFAULT', 2269 hkFeature, mcFuel); 2270 if MyRO.Happened and phPeaceEvacuation <> 0 then 2271 for p1 := 0 to nPl - 1 do 2272 if 1 shl p1 and MyData.PeaceEvaHappened <> 0 then 2273 SoundMessageEx(Tribe[p1].TPhrase('WITHDRAW'), 'MSG_DEFAULT'); 2274 if MyRO.Happened and phPeaceViolation <> 0 then 2275 for p1 := 0 to nPl - 1 do 2276 if (1 shl p1 and MyRO.Alive <> 0) and (MyRO.EvaStart[p1] = MyRO.Turn) 2277 then 2278 SoundMessageEx(Format(Tribe[p1].TPhrase('VIOLATION'), 2279 [TurnToString(MyRO.Turn + PeaceEvaTurns - 1)]), 'MSG_WITHDRAW'); 2280 TellNewContacts; 2281 end; 2282 2283 if ClientMode = cMovieTurn then 2284 Update 2285 else if ClientMode = cTurn then 2286 begin 2287 if UpdatePanel then 2288 UpdateViews; 2289 Application.ProcessMessages; 2290 2291 if not supervising then 2292 for uix := 0 to MyRO.nUn - 1 do 2293 with MyUn[uix] do 2294 if Loc >= 0 then 2295 begin 2296 if Flags and unWithdrawn <> 0 then 2297 Status := 0; 2298 if Health = 100 then 2299 Status := Status and not usRecover; 2300 if (Master >= 0) or UnitExhausted(uix) then 2301 Status := Status and not usWaiting 2302 else 2303 Status := Status or usWaiting; 2304 CheckToldNoReturn(uix); 2305 if Status and usGoto <> 0 then 2306 begin { continue multi-turn goto } 2307 SetUnFocus(uix); 2308 SetTroopLoc(Loc); 2309 FocusOnLoc(TroopLoc, flRepaintPanel or flImmUpdate); 2310 if Status shr 16 = $7FFF then 2311 MoveResult := GetMoveAdvice(UnFocus, maNextCity, 2312 MoveAdviceData) 2313 else 2314 MoveResult := GetMoveAdvice(UnFocus, Status shr 16, 2315 MoveAdviceData); 2316 if MoveResult >= rExecuted then 2317 begin // !!! Shinkansen 2318 MoveResult := eOK; 2319 ok := true; 2320 for i := 0 to MoveAdviceData.nStep - 1 do 2321 begin 2322 Loc1 := dLoc(Loc, MoveAdviceData.dx[i], 2323 MoveAdviceData.dy[i]); 2324 if (MyMap[Loc1] and (fCity or fOwned) = fCity) 2325 // don't capture cities during auto move 2326 or (MyMap[Loc1] and (fUnit or fOwned) = fUnit) then 2327 // don't attack during auto move 2198 2328 begin 2199 if AutoBuild(cix, MyData.ImpOrder[Status and 7 - 1]) then 2200 AllowCityScreen := false 2201 else if Flags and chProduction <> 0 then 2202 Flags := (Flags and not chProduction) or chAllImpsMade 2329 ok := false; 2330 Break 2203 2331 end 2204 2332 else 2205 Flags := Flags or chTypeDel;2206 if (Size >= NeedAqueductSize) and2207 (MyRO.Tech[Imp[imAqueduct].Preq] < tsApplicable) or2208 (Size >= NeedSewerSize) and2209 (MyRO.Tech[Imp[imSewer].Preq] < tsApplicable) then2210 Flags := Flags and not chNoGrowthWarning;2211 // don't remind of unknown building2212 if Flags and chNoSettlerProd = 0 then2213 Status := Status and not csToldDelay2214 else if Status and csToldDelay = 0 then2215 Status := Status or csToldDelay2216 else2217 Flags := Flags and not chNoSettlerProd;2218 if mRepScreens.Checked then2219 begin2220 if (Flags and CityRepMask <> 0) and AllowCityScreen then2221 begin { show what happened in cities }2222 SetTroopLoc(MyCity[cix].Loc);2223 MarkCityLoc := MyCity[cix].Loc;2224 PanelPaint;2225 CityDlg.CloseAction := None;2226 CityDlg.ShowNewContent(wmModal, MyCity[cix].Loc,2227 Flags and CityRepMask);2228 UpdatePanel := true;2229 end2230 end2231 else { if mRepList.Checked then }2232 begin2233 if Flags and CityRepMask <> 0 then2234 ShowCityList := true2235 end2236 end2237 end; { city loop }2238 end; // ClientMode=cTurn2239 2240 if ClientMode = cTurn then2241 begin2242 if NewGovAvailable >= 0 then2243 with MessgExDlg do2244 begin2245 MessgText := Format(Phrases.Lookup('AUTOREVOLUTION'),2246 [Phrases.Lookup('GOVERNMENT', NewGovAvailable)]);2247 Kind := mkYesNo;2248 IconKind := mikPureIcon;2249 IconIndex := 6 + NewGovAvailable;2250 ShowModal;2251 if ModalResult = mrOK then2252 begin2253 Play('REVOLUTION');2254 Server(sRevolution, me, 0, nil^);2255 end2256 end;2257 end; // ClientMode=cTurn2258 2259 if (ClientMode = cTurn) or (ClientMode = cMovieTurn) then2260 begin2261 if MyRO.Happened and phGliderLost <> 0 then2262 ContextMessage(Phrases.Lookup('GLIDERLOST'), 'MSG_DEFAULT',2263 hkModel, 200);2264 if MyRO.Happened and phPlaneLost <> 0 then2265 ContextMessage(Phrases.Lookup('PLANELOST'), 'MSG_DEFAULT',2266 hkFeature, mcFuel);2267 if MyRO.Happened and phPeaceEvacuation <> 0 then2268 for p1 := 0 to nPl - 1 do2269 if 1 shl p1 and MyData.PeaceEvaHappened <> 0 then2270 SoundMessageEx(Tribe[p1].TPhrase('WITHDRAW'), 'MSG_DEFAULT');2271 if MyRO.Happened and phPeaceViolation <> 0 then2272 for p1 := 0 to nPl - 1 do2273 if (1 shl p1 and MyRO.Alive <> 0) and (MyRO.EvaStart[p1] = MyRO.Turn)2274 then2275 SoundMessageEx(Format(Tribe[p1].TPhrase('VIOLATION'),2276 [TurnToString(MyRO.Turn + PeaceEvaTurns - 1)]), 'MSG_WITHDRAW');2277 TellNewContacts;2278 end;2279 2280 if ClientMode = cMovieTurn then2281 Update2282 else if ClientMode = cTurn then2283 begin2284 if UpdatePanel then2285 UpdateViews;2286 Application.ProcessMessages;2287 2288 if not supervising then2289 for uix := 0 to MyRO.nUn - 1 do2290 with MyUn[uix] do2291 if Loc >= 0 then2292 begin2293 if Flags and unWithdrawn <> 0 then2294 Status := 0;2295 if Health = 100 then2296 Status := Status and not usRecover;2297 if (Master >= 0) or UnitExhausted(uix) then2298 Status := Status and not usWaiting2299 else2300 Status := Status or usWaiting;2301 CheckToldNoReturn(uix);2302 if Status and usGoto <> 0 then2303 begin { continue multi-turn goto }2304 SetUnFocus(uix);2305 SetTroopLoc(Loc);2306 FocusOnLoc(TroopLoc, flRepaintPanel or flImmUpdate);2307 if Status shr 16 = $7FFF then2308 MoveResult := GetMoveAdvice(UnFocus, maNextCity,2309 MoveAdviceData)2310 else2311 MoveResult := GetMoveAdvice(UnFocus, Status shr 16,2312 MoveAdviceData);2313 if MoveResult >= rExecuted then2314 begin // !!! Shinkansen2315 MoveResult := eOK;2316 ok := true;2317 for i := 0 to MoveAdviceData.nStep - 1 do2318 2333 begin 2319 Loc1 := dLoc(Loc, MoveAdviceData.dx[i], 2320 MoveAdviceData.dy[i]); 2321 if (MyMap[Loc1] and (fCity or fOwned) = fCity) 2322 // don't capture cities during auto move 2323 or (MyMap[Loc1] and (fUnit or fOwned) = fUnit) then 2324 // don't attack during auto move 2334 if (Loc1 = MoveAdviceData.ToLoc) or 2335 (MoveAdviceData.ToLoc = maNextCity) and 2336 (MyMap[dLoc(Loc, MoveAdviceData.dx[i], 2337 MoveAdviceData.dy[i])] and fCity <> 0) then 2338 MoveOptions := muAutoNoWait 2339 else 2340 MoveOptions := 0; 2341 MoveResult := MoveUnit(MoveAdviceData.dx[i], 2342 MoveAdviceData.dy[i], MoveOptions); 2343 if (MoveResult < rExecuted) or (MoveResult = eEnemySpotted) 2344 then 2325 2345 begin 2326 2346 ok := false; 2327 2347 Break 2328 end 2329 else 2330 begin 2331 if (Loc1 = MoveAdviceData.ToLoc) or 2332 (MoveAdviceData.ToLoc = maNextCity) and 2333 (MyMap[dLoc(Loc, MoveAdviceData.dx[i], 2334 MoveAdviceData.dy[i])] and fCity <> 0) then 2335 MoveOptions := muAutoNoWait 2336 else 2337 MoveOptions := 0; 2338 MoveResult := MoveUnit(MoveAdviceData.dx[i], 2339 MoveAdviceData.dy[i], MoveOptions); 2340 if (MoveResult < rExecuted) or (MoveResult = eEnemySpotted) 2341 then 2342 begin 2343 ok := false; 2344 Break 2345 end; 2346 end 2347 end; 2348 Stop := not ok or (Loc = MoveAdviceData.ToLoc) or 2349 (MoveAdviceData.ToLoc = maNextCity) and 2350 (MyMap[Loc] and fCity <> 0) 2351 end 2348 end; 2349 end 2350 end; 2351 Stop := not ok or (Loc = MoveAdviceData.ToLoc) or 2352 (MoveAdviceData.ToLoc = maNextCity) and 2353 (MyMap[Loc] and fCity <> 0) 2354 end 2355 else 2356 begin 2357 MoveResult := eOK; 2358 Stop := true; 2359 end; 2360 2361 if MoveResult <> eDied then 2362 if Stop then 2363 Status := Status and ($FFFF - usGoto) 2352 2364 else 2353 begin 2354 MoveResult := eOK; 2355 Stop := true; 2356 end; 2357 2358 if MoveResult <> eDied then 2359 if Stop then 2360 Status := Status and ($FFFF - usGoto) 2361 else 2362 Status := Status and not usWaiting; 2363 end; 2364 2365 if Status and (usEnhance or usGoto) = usEnhance then 2366 // continue terrain enhancement 2367 begin 2368 MoveResult := ProcessEnhancement(uix, MyData.EnhancementJobs); 2369 if MoveResult <> eDied then 2370 if MoveResult = eJobDone then 2371 Status := Status and not usEnhance 2372 else 2373 Status := Status and not usWaiting; 2374 end 2365 Status := Status and not usWaiting; 2375 2366 end; 2376 end; // ClientMode=cTurn 2377 2378 HaveStrategyAdvice := false; 2379 // (GameMode<>cMovie) and not supervising 2380 // and AdvisorDlg.HaveStrategyAdvice; 2381 GoOnPhase := true; 2382 if supervising or (GameMode = cMovie) then 2383 begin 2367 2368 if Status and (usEnhance or usGoto) = usEnhance then 2369 // continue terrain enhancement 2370 begin 2371 MoveResult := ProcessEnhancement(uix, MyData.EnhancementJobs); 2372 if MoveResult <> eDied then 2373 if MoveResult = eJobDone then 2374 Status := Status and not usEnhance 2375 else 2376 Status := Status and not usWaiting; 2377 end 2378 end; 2379 end; // ClientMode=cTurn 2380 2381 HaveStrategyAdvice := false; 2382 // (GameMode<>cMovie) and not supervising 2383 // and AdvisorDlg.HaveStrategyAdvice; 2384 GoOnPhase := true; 2385 if supervising or (GameMode = cMovie) then 2386 begin 2387 SetTroopLoc(-1); 2388 PaintAll 2389 end { supervisor } 2390 { else if (ClientMode=cTurn) and (MyRO.Turn=0) then 2391 begin 2392 SetUnFocus(0); 2393 ZoomToCity(MyCity[0].Loc) 2394 end } 2395 else 2396 begin 2397 if ClientMode >= scContact then 2398 SetUnFocus(-1) 2399 else 2400 NextUnit(-1, false); 2401 if UnFocus < 0 then 2402 begin 2403 UnStartLoc := -1; 2404 if IsMultiPlayerGame or (ClientMode = cResume) then 2405 if MyRO.nCity > 0 then 2406 FocusOnLoc(MyCity[0].Loc) 2407 else 2408 FocusOnLoc(G.lx * G.ly div 2); 2384 2409 SetTroopLoc(-1); 2385 PaintAll 2386 end { supervisor } 2387 { else if (ClientMode=cTurn) and (MyRO.Turn=0) then 2388 begin 2389 SetUnFocus(0); 2390 ZoomToCity(MyCity[0].Loc) 2391 end } 2392 else 2393 begin 2394 if ClientMode >= scContact then 2395 SetUnFocus(-1) 2396 else 2397 NextUnit(-1, false); 2398 if UnFocus < 0 then 2399 begin 2400 UnStartLoc := -1; 2401 if IsMultiPlayerGame or (ClientMode = cResume) then 2402 if MyRO.nCity > 0 then 2403 FocusOnLoc(MyCity[0].Loc) 2404 else 2405 FocusOnLoc(G.lx * G.ly div 2); 2406 SetTroopLoc(-1); 2407 PanelPaint 2408 end; 2409 if ShowCityList then 2410 ListDlg.ShowNewContent(wmPersistent, kCityEvents); 2410 PanelPaint 2411 2411 end; 2412 end; { InitTurn } 2413 2412 if ShowCityList then 2413 ListDlg.ShowNewContent(wmPersistent, kCityEvents); 2414 end; 2415 end; 2416 2417 procedure TMainScreen.Client(Command, NewPlayer: integer; var Data); 2414 2418 var 2415 2419 i, j, p1, mix, ToLoc, AnimationSpeed, ShowMoveDomain, cix, ecix: integer; … … 2419 2423 mi: TModelInfo; 2420 2424 SkipTurn, IsAlpine, IsTreatyDeal: boolean; 2421 2422 begin { >>>client } 2425 begin 2423 2426 case Command of 2424 2427 cTurn, cResume, cContinue, cMovieTurn, scContact, scDipStart .. scDipBreak: … … 3392 3395 end 3393 3396 end 3394 end; { <<<client }3397 end; 3395 3398 3396 3399 { *** main part *** }
Note:
See TracChangeset
for help on using the changeset viewer.