Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

Merge branch 'bugfixes' into 3.1

  • Loading branch information...
commit 584fb55c99ed46a14b2e302e9991b03fb3c00863 2 parents 5997d95 + b782d21
automerge authored cybersphinx committed
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
39 data/mp/multiplay/skirmish/semperfi.js
@@ -129,9 +129,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)
@@ -245,7 +243,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,30 +301,30 @@ function buildFundamentals()
function buildFundamentals2()
{
// Need factories? FIXME, check real limits
- var factlist = enumStruct(me, factory);
- var reslist = enumStruct(me, resLab);
- var hqlist = enumStruct(me, playerHQ);
+ var factcount = countStruct(factory);
+ var rescount = countStruct(resLab);
+ var hqcount = countStruct(playerHQ);
// Build as many research labs as factories
- if (reslist.length < factlist.length && grabTrucksAndBuild(20, resLab, 1))
+ if (rescount < factcount && grabTrucksAndBuild(20, resLab, 1))
{
return;
}
// Build as many factories as we can afford
- if ((factlist.length < 2 || (factlist.length < 4 && playerPower(me) > factlist.length * 1000))
+ if ((factcount < 2 || (factcount < 4 && playerPower(me) > factcount * 1000))
&& grabTrucksAndBuild(20, factory, 1))
{
return; // done here
}
// Build HQ if missing
- if (hqlist.length == 0 && grabTrucksAndBuild(20, playerHQ, 1))
+ if (hqcount == 0 && grabTrucksAndBuild(20, playerHQ, 1))
{
return;
}
// Build cyborg factory if we don't have one
if (isStructureAvailable(cybFactory, me))
{
- var cyblist = enumStruct(me, cybFactory);
- if (cyblist.length == 0 && playerPower(me) > 250 && grabTrucksAndBuild(20, cybFactory, 1))
+ var cybcount = countStruct(cybFactory);
+ if (cybcount == 0 && playerPower(me) > 250 && grabTrucksAndBuild(20, cybFactory, 1))
{
return;
}
@@ -335,8 +332,8 @@ function buildFundamentals2()
// Build VTOL factory if we don't have one
if (isStructureAvailable(me, vtolFactory))
{
- var vfaclist = enumStruct(me, vtolFactory);
- if (vfaclist.length == 0 && playerPower(me) > 500 && grabTrucksAndBuild(20, vtolFactory, 1))
+ var vfaccount = countStruct(vtolFactory);
+ if (vfaccount == 0 && playerPower(me) > 500 && grabTrucksAndBuild(20, vtolFactory, 1))
{
return;
}
@@ -463,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);
}
@@ -595,17 +591,6 @@ function eventStartLevel()
// Maintenance calls - to fix quirks
setTimer("maintenance", 1000 * 60 * 2); // every 2 minutes, call it to check if anything left to do
-
- /*
- if (numFactories() > 1 && isStructureAvailable(defStructs[0], me) && playerData[me].difficulty > MEDIUM)
- {
- dbgPlr("TRUCK RUSH!");
- queue("truckRush");
- }
- else
- {
- queue("buildFundamentals");
- }*/
}
function eventDroidIdle(droid)
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/droiddef.h
@@ -76,7 +76,7 @@ enum DROID_TYPE
DROID_CYBORG_REPAIR, ///< cyborg repair droid - new for update 28/5/99
DROID_CYBORG_SUPER, ///< cyborg repair droid - new for update 7/6/99
DROID_SUPERTRANSPORTER, ///< SuperTransport (MP)
- DROID_ANY, ///< Any droid. Only used as a parameter for intGotoNextDroidType(DROID_TYPE).
+ DROID_ANY, ///< Any droid
};
struct COMPONENT
View
2  src/game.cpp
@@ -4808,7 +4808,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
@@ -5084,7 +5083,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
69 src/qtscriptfuncs.cpp
@@ -53,6 +53,9 @@
#include "scriptextern.h"
#define FAKE_REF_LASSAT 999
+#define ALL_PLAYERS -1
+#define ALLIES -2
+#define ENEMIES -3
// hack, this is used from scriptfuncs.cpp -- and we don't want to include any stinkin' wzscript headers here!
// TODO, move this stuff into a script common subsystem
@@ -1964,13 +1967,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();
@@ -1980,7 +1985,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)}
@@ -2189,7 +2243,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));
@@ -2232,6 +2287,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);
@@ -2254,6 +2310,9 @@ bool registerFunctions(QScriptEngine *engine)
engine->globalObject().setProperty("STRUCTURE", OBJ_STRUCTURE, QScriptValue::ReadOnly | QScriptValue::Undeletable);
engine->globalObject().setProperty("DROID", OBJ_DROID, QScriptValue::ReadOnly | QScriptValue::Undeletable);
engine->globalObject().setProperty("FEATURE", OBJ_FEATURE, QScriptValue::ReadOnly | QScriptValue::Undeletable);
+ engine->globalObject().setProperty("ALL_PLAYERS", ALL_PLAYERS, QScriptValue::ReadOnly | QScriptValue::Undeletable);
+ engine->globalObject().setProperty("ALLIES", ALLIES, QScriptValue::ReadOnly | QScriptValue::Undeletable);
+ engine->globalObject().setProperty("ENEMIES", ENEMIES, QScriptValue::ReadOnly | QScriptValue::Undeletable);
engine->globalObject().setProperty("POSITION", SCRIPT_POSITION, QScriptValue::ReadOnly | QScriptValue::Undeletable);
engine->globalObject().setProperty("AREA", SCRIPT_AREA, QScriptValue::ReadOnly | QScriptValue::Undeletable);
engine->globalObject().setProperty("PLAYER_DATA", SCRIPT_PLAYER, QScriptValue::ReadOnly | QScriptValue::Undeletable);
Please sign in to comment.
Something went wrong with that request. Please try again.