Ticket #3880: autostart.patch
File autostart.patch, 3.0 KB (added by , 8 years ago) |
---|
-
source/ps/GameSetup/GameSetup.cpp
1324 1324 scriptInterface.SetProperty(settings, "AISeed", aiseed); 1325 1325 1326 1326 // Set player data for AIs 1327 // attrs.settings = { PlayerData: [ { AI: ... }, ... ] }: 1327 // attrs.settings = { PlayerData: [ { AI: ... }, ... ] } 1328 // or = { PlayerData: [ null, { AI: ... }, ... ] } when gaia set 1329 int i0 = 1; 1330 JS::RootedValue player(cx); 1331 if (scriptInterface.GetPropertyInt(playerData, 0, &player) && player.isNull()) 1332 i0 = 0; 1333 1328 1334 if (args.Has("autostart-ai")) 1329 1335 { 1330 1336 std::vector<CStr> aiArgs = args.GetMultiple("autostart-ai"); … … 1334 1340 1335 1341 // Instead of overwriting existing player data, modify the array 1336 1342 JS::RootedValue player(cx); 1337 if (!scriptInterface.GetPropertyInt(playerData, playerID- 1, &player) || player.isUndefined())1343 if (!scriptInterface.GetPropertyInt(playerData, playerID-i0, &player) || player.isUndefined()) 1338 1344 { 1339 1345 if (mapDirectory == L"scenarios" || mapDirectory == L"skirmishes") 1340 1346 { … … 1348 1354 CStr name = aiArgs[i].AfterFirst(":"); 1349 1355 scriptInterface.SetProperty(player, "AI", std::string(name)); 1350 1356 scriptInterface.SetProperty(player, "AIDiff", 3); 1351 scriptInterface.SetPropertyInt(playerData, playerID- 1, player);1357 scriptInterface.SetPropertyInt(playerData, playerID-i0, player); 1352 1358 } 1353 1359 } 1354 1360 // Set AI difficulty … … 1361 1367 1362 1368 // Instead of overwriting existing player data, modify the array 1363 1369 JS::RootedValue player(cx); 1364 if (!scriptInterface.GetPropertyInt(playerData, playerID- 1, &player) || player.isUndefined())1370 if (!scriptInterface.GetPropertyInt(playerData, playerID-i0, &player) || player.isUndefined()) 1365 1371 { 1366 1372 if (mapDirectory == L"scenarios" || mapDirectory == L"skirmishes") 1367 1373 { … … 1374 1380 1375 1381 int difficulty = civArgs[i].AfterFirst(":").ToInt(); 1376 1382 scriptInterface.SetProperty(player, "AIDiff", difficulty); 1377 scriptInterface.SetPropertyInt(playerData, playerID- 1, player);1383 scriptInterface.SetPropertyInt(playerData, playerID-i0, player); 1378 1384 } 1379 1385 } 1380 1386 // Set player data for Civs … … 1389 1395 1390 1396 // Instead of overwriting existing player data, modify the array 1391 1397 JS::RootedValue player(cx); 1392 if (!scriptInterface.GetPropertyInt(playerData, playerID- 1, &player) || player.isUndefined())1398 if (!scriptInterface.GetPropertyInt(playerData, playerID-i0, &player) || player.isUndefined()) 1393 1399 { 1394 1400 if (mapDirectory == L"skirmishes") 1395 1401 { … … 1400 1406 scriptInterface.Eval("({})", &player); 1401 1407 } 1402 1408 1403 CStr name = civArgs[i].AfterFirst(":"); 1409 CStr name = civArgs[i].AfterFirst(":"); 1404 1410 scriptInterface.SetProperty(player, "Civ", std::string(name)); 1405 scriptInterface.SetPropertyInt(playerData, playerID- 1, player);1411 scriptInterface.SetPropertyInt(playerData, playerID-i0, player); 1406 1412 } 1407 1413 } 1408 1414 else