Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

Merge remote-tracking branch 'origin/bugfixes'

Conflicts:
	data/mp/multiplay/skirmish/semperfi.js
	src/droiddef.h
  • Loading branch information...
commit 67cc1ec0413da2f0077d2f1df2b934e2848d4946 2 parents d0a57ed + b782d21
@perim perim authored
View
4 ChangeLog
@@ -1,10 +1,12 @@
2012-10-NN: Version 3.1.0
+ * General:
+ * Factories with a module addon no longer become better each save/load cycle (ticket:3732, commit:13b07b78dd85da1889843164d390ccb9d0a8f62b)
* Build system:
* New version of autorevision fixes MSVC builds (ticket:3765)
* Multiplayer:
* Change: AI droids shoot at blocking features again, and can move through each other when jammed (commit:a19e41c15d78106c7128e63662e8824454b8900c)
* Scripting:
- * New: Functions getStructureLimit() and getStructureCount() (commit:af757d28bd082384355272f890fe6d79fd5369a8)
+ * New: getStructureLimit(), countDroid() and countStruct() (commit:af757d28bd082384355272f890fe6d79fd5369a8, commit:def9fb81c34a7c6d3c343c659507ed1b6f40f5ee)
* New: orderDroidBuild() now takes an optional direction parameter for rotation (commit:24414caa0c6a8db7459e7204a1c12546d27f7441)
2012-10-08: Version 3.1 rc3
View
24 data/mp/multiplay/skirmish/semperfi.js
@@ -130,9 +130,7 @@ function buildVTOL(struct)
// If negative, we have too many power generator (usually not a problem in itself).
function numUnusedDerricks()
{
- var derricklist = enumStruct(me, derrick);
- var powgenlist = enumStruct(me, powGen);
- return derricklist.length - powgenlist.length * 4;
+ return countStruct(derrick) - countStruct(powGen) * 4;
}
function conCanHelp(mydroid, bx, by)
@@ -246,7 +244,6 @@ function sortByDistToBase(obj1, obj2)
function buildFundamentals()
{
var needPwGen = false;
- var factlist = enumStruct(me, factory);
var droids = enumDroid(me, DROID_CONSTRUCT);
// Do we need power generators?
@@ -304,33 +301,30 @@ function buildFundamentals()
function buildFundamentals2()
{
- var factlist = enumStruct(me, factory);
+ var factcount = countStruct(factory);
// Build as many research labs as factories
if (!researchDone && isStructureAvailable(resLab))
{
- var reslist = enumStruct(me, resLab);
- if (reslist.length < factlist.length && grabTrucksAndBuild(20, resLab, 1))
+ if (countStruct(resLab) < factcount && grabTrucksAndBuild(20, resLab, 1))
{
return; // done here
}
}
// Build as many factories as we can afford
- if ((factlist.length < 2 || (factlist.length < 4 && playerPower(me) > factlist.length * 750))
+ if ((factcount < 2 || (factcount < 4 && playerPower(me) > factcount * 750))
&& isStructureAvailable(factory) && grabTrucksAndBuild(20, factory, 1))
{
return; // done here
}
// Build HQ if missing
- var hqlist = enumStruct(me, playerHQ);
- if (isStructureAvailable(playerHQ) && hqlist.length == 0 && grabTrucksAndBuild(20, playerHQ, 1))
+ if (isStructureAvailable(playerHQ) && countStruct(playerHQ) == 0 && grabTrucksAndBuild(20, playerHQ, 1))
{
return;
}
// Build cyborg factory if we don't have one
if (isStructureAvailable(cybFactory))
{
- var cyblist = enumStruct(me, cybFactory);
- if (cyblist.length == 0 && playerPower(me) > 250 && grabTrucksAndBuild(20, cybFactory, 1))
+ if (countStruct(cybFactory) == 0 && playerPower(me) > 250 && grabTrucksAndBuild(20, cybFactory, 1))
{
return;
}
@@ -338,8 +332,7 @@ function buildFundamentals2()
// Build VTOL factory if we don't have one
if (isStructureAvailable(vtolFactory))
{
- var vfaclist = enumStruct(me, vtolFactory);
- if (vfaclist.length == 0 && playerPower(me) > 500 && grabTrucksAndBuild(20, vtolFactory, 1))
+ if (countStruct(vtolFactory) == 0 && playerPower(me) > 500 && grabTrucksAndBuild(20, vtolFactory, 1))
{
return;
}
@@ -467,8 +460,7 @@ function eventDroidBuilt(droid, struct)
{
if (struct.stattype == FACTORY)
{
- var trucklist = enumDroid(me, DROID_CONSTRUCT);
- if (trucklist.length < 6)
+ if (countDroid(DROID_CONSTRUCT) < 6)
{
buildTruck(struct);
}
View
4 macosx/configs/fetchscripts/SetupPrebuiltComponents-Docs.sh
@@ -1,10 +1,10 @@
#!/bin/sh
OutDir="WarzoneHelp"
-DirectorY="${OutDir}-a9c2db1"
+DirectorY="${OutDir}-5997d95"
FileName="${DirectorY}.tgz"
BuiltDLP="http://downloads.sourceforge.net/project/warzone2100/build-tools/mac/${FileName}"
-MD5Sum="591d5dc15c4e56a61eb8e4433de31a8d"
+MD5Sum="72c0fd20b480892b6bcd9d9c31810491"
configs/FetchPrebuilt.sh "${DirectorY}" "${OutDir}" "${FileName}" "${BuiltDLP}" "${MD5Sum}"
exit ${?}
View
2  src/game.cpp
@@ -4836,7 +4836,6 @@ static bool loadSaveStructure2(const char *pFileName, STRUCTURE **ppList)
psFactory->buildPointsRemaining = ini.value("Factory/buildPointsRemaining", psFactory->buildPointsRemaining).toInt();
psFactory->timeStartHold = ini.value("Factory/timeStartHold", psFactory->timeStartHold).toInt();
psFactory->loopsPerformed = ini.value("Factory/loopsPerformed", psFactory->loopsPerformed).toInt();
- psFactory->productionOutput = ini.value("Factory/productionOutput", psFactory->productionOutput).toInt();
// statusPending and pendingCount belong to the GUI, not the game state.
psFactory->secondaryOrder = ini.value("Factory/secondaryOrder", psFactory->secondaryOrder).toInt();
//adjust the module structures IMD
@@ -5111,7 +5110,6 @@ bool writeStructFile(const char *pFileName)
ini.setValue("Factory/buildPointsRemaining", psFactory->buildPointsRemaining);
ini.setValue("Factory/timeStartHold", psFactory->timeStartHold);
ini.setValue("Factory/loopsPerformed", psFactory->loopsPerformed);
- ini.setValue("Factory/productionOutput", psFactory->productionOutput);
// statusPending and pendingCount belong to the GUI, not the game state.
ini.setValue("Factory/secondaryOrder", psFactory->secondaryOrder);
View
63 src/qtscriptfuncs.cpp
@@ -2307,13 +2307,15 @@ static QScriptValue js_getStructureLimit(QScriptContext *context, QScriptEngine
return QScriptValue(asStructLimits[player][index].limit);
}
-//-- \subsection{getStructureCount(structure type[, player])}
-//-- Create a structure on the given position. Returns true on success.
-static QScriptValue js_getStructureCount(QScriptContext *context, QScriptEngine *engine)
+//-- \subsection{countStruct(structure type[, player])}
+//-- Count the number of structures of a given type.
+//-- The player parameter can be a specific player, ALL_PLAYERS, ALLIES or ENEMIES.
+static QScriptValue js_countStruct(QScriptContext *context, QScriptEngine *engine)
{
QString building = context->argument(0).toString();
int index = getStructStatFromName(building.toUtf8().constData());
int player;
+ int quantity = 0;
if (context->argumentCount() > 1)
{
player = context->argument(1).toInt32();
@@ -2323,7 +2325,56 @@ static QScriptValue js_getStructureCount(QScriptContext *context, QScriptEngine
player = engine->globalObject().property("me").toInt32();
}
SCRIPT_ASSERT(context, index < numStructureStats && index >= 0, "Structure %s not found", building.toUtf8().constData());
- return QScriptValue(asStructLimits[player][index].currentQuantity);
+ for (int i = 0; i < MAX_PLAYERS; i++)
+ {
+ if (player == i || player == ALL_PLAYERS
+ || (player == ALLIES && aiCheckAlliances(i, player))
+ || (player == ENEMIES && !aiCheckAlliances(i, player)))
+ {
+ quantity += asStructLimits[i][index].currentQuantity;
+ }
+ }
+ return QScriptValue(quantity);
+}
+
+//-- \subsection{countDroid(droid type[, player])}
+//-- Count the number of droids that a given player has. Droid type must be either
+//-- DROID_ANY, DROID_COMMAND or DROID_CONSTRUCT.
+//-- The player parameter can be a specific player, ALL_PLAYERS, ALLIES or ENEMIES.
+static QScriptValue js_countDroid(QScriptContext *context, QScriptEngine *engine)
+{
+ int player;
+ int quantity = 0;
+ int type = context->argument(0).toInt32();
+ if (context->argumentCount() > 1)
+ {
+ player = context->argument(1).toInt32();
+ }
+ else
+ {
+ player = engine->globalObject().property("me").toInt32();
+ }
+ for (int i = 0; i < MAX_PLAYERS; i++)
+ {
+ if (player == i || player == ALL_PLAYERS
+ || (player == ALLIES && aiCheckAlliances(i, player))
+ || (player == ENEMIES && !aiCheckAlliances(i, player)))
+ {
+ if (type == DROID_ANY)
+ {
+ quantity += getNumDroids(i);
+ }
+ else if (type == DROID_CONSTRUCT)
+ {
+ quantity += getNumConstructorDroids(i);
+ }
+ else if (type == DROID_COMMAND)
+ {
+ quantity += getNumCommandDroids(i);
+ }
+ }
+ }
+ return QScriptValue(quantity);
}
//-- \subsection{setNoGoArea(x1, y1, x2, y2, player)}
@@ -2751,7 +2802,8 @@ bool registerFunctions(QScriptEngine *engine)
engine->globalObject().setProperty("setScrollParams", engine->newFunction(js_setScrollParams));
engine->globalObject().setProperty("addStructure", engine->newFunction(js_addStructure));
engine->globalObject().setProperty("getStructureLimit", engine->newFunction(js_getStructureLimit));
- engine->globalObject().setProperty("getStructureCount", engine->newFunction(js_getStructureCount));
+ engine->globalObject().setProperty("countStruct", engine->newFunction(js_countStruct));
+ engine->globalObject().setProperty("countDroid", engine->newFunction(js_countDroid));
engine->globalObject().setProperty("loadLevel", engine->newFunction(js_loadLevel));
engine->globalObject().setProperty("setDroidExperience", engine->newFunction(js_setDroidExperience));
engine->globalObject().setProperty("setNoGoArea", engine->newFunction(js_setNoGoArea));
@@ -2802,6 +2854,7 @@ bool registerFunctions(QScriptEngine *engine)
engine->globalObject().setProperty("DROID_TRANSPORTER", DROID_TRANSPORTER, QScriptValue::ReadOnly | QScriptValue::Undeletable);
engine->globalObject().setProperty("DROID_SUPERTRANSPORTER", DROID_SUPERTRANSPORTER, QScriptValue::ReadOnly | QScriptValue::Undeletable);
engine->globalObject().setProperty("DROID_COMMAND", DROID_COMMAND, QScriptValue::ReadOnly | QScriptValue::Undeletable);
+ engine->globalObject().setProperty("DROID_ANY", DROID_ANY, QScriptValue::ReadOnly | QScriptValue::Undeletable);
engine->globalObject().setProperty("HQ", REF_HQ, QScriptValue::ReadOnly | QScriptValue::Undeletable);
engine->globalObject().setProperty("FACTORY", REF_FACTORY, QScriptValue::ReadOnly | QScriptValue::Undeletable);
engine->globalObject().setProperty("POWER_GEN", REF_POWER_GEN, QScriptValue::ReadOnly | QScriptValue::Undeletable);
Please sign in to comment.
Something went wrong with that request. Please try again.