Skip to content

Commit

Permalink
Merge branch 'bugfixes' into 3.1
Browse files Browse the repository at this point in the history
  • Loading branch information
automerge authored and cybersphinx committed Nov 5, 2012
2 parents 5997d95 + b782d21 commit 584fb55
Show file tree
Hide file tree
Showing 6 changed files with 82 additions and 38 deletions.
4 changes: 3 additions & 1 deletion ChangeLog
Original file line number Original file line Diff line number Diff line change
@@ -1,10 +1,12 @@
2012-10-NN: Version 3.1.0 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: * Build system:
* New version of autorevision fixes MSVC builds (ticket:3765) * New version of autorevision fixes MSVC builds (ticket:3765)
* Multiplayer: * Multiplayer:
* Change: AI droids shoot at blocking features again, and can move through each other when jammed (commit:a19e41c15d78106c7128e63662e8824454b8900c) * Change: AI droids shoot at blocking features again, and can move through each other when jammed (commit:a19e41c15d78106c7128e63662e8824454b8900c)
* Scripting: * 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) * New: orderDroidBuild() now takes an optional direction parameter for rotation (commit:24414caa0c6a8db7459e7204a1c12546d27f7441)


2012-10-08: Version 3.1 rc3 2012-10-08: Version 3.1 rc3
Expand Down
39 changes: 12 additions & 27 deletions data/mp/multiplay/skirmish/semperfi.js
Original file line number Original file line Diff line number Diff line change
Expand Up @@ -129,9 +129,7 @@ function buildVTOL(struct)
// If negative, we have too many power generator (usually not a problem in itself). // If negative, we have too many power generator (usually not a problem in itself).
function numUnusedDerricks() function numUnusedDerricks()
{ {
var derricklist = enumStruct(me, derrick); return countStruct(derrick) - countStruct(powGen) * 4;
var powgenlist = enumStruct(me, powGen);
return derricklist.length - powgenlist.length * 4;
} }


function conCanHelp(mydroid, bx, by) function conCanHelp(mydroid, bx, by)
Expand Down Expand Up @@ -245,7 +243,6 @@ function sortByDistToBase(obj1, obj2)
function buildFundamentals() function buildFundamentals()
{ {
var needPwGen = false; var needPwGen = false;
var factlist = enumStruct(me, factory);
var droids = enumDroid(me, DROID_CONSTRUCT); var droids = enumDroid(me, DROID_CONSTRUCT);


// Do we need power generators? // Do we need power generators?
Expand Down Expand Up @@ -304,39 +301,39 @@ function buildFundamentals()
function buildFundamentals2() function buildFundamentals2()
{ {
// Need factories? FIXME, check real limits // Need factories? FIXME, check real limits
var factlist = enumStruct(me, factory); var factcount = countStruct(factory);
var reslist = enumStruct(me, resLab); var rescount = countStruct(resLab);
var hqlist = enumStruct(me, playerHQ); var hqcount = countStruct(playerHQ);
// Build as many research labs as factories // Build as many research labs as factories
if (reslist.length < factlist.length && grabTrucksAndBuild(20, resLab, 1)) if (rescount < factcount && grabTrucksAndBuild(20, resLab, 1))
{ {
return; return;
} }
// Build as many factories as we can afford // 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)) && grabTrucksAndBuild(20, factory, 1))
{ {
return; // done here return; // done here
} }
// Build HQ if missing // Build HQ if missing
if (hqlist.length == 0 && grabTrucksAndBuild(20, playerHQ, 1)) if (hqcount == 0 && grabTrucksAndBuild(20, playerHQ, 1))
{ {
return; return;
} }
// Build cyborg factory if we don't have one // Build cyborg factory if we don't have one
if (isStructureAvailable(cybFactory, me)) if (isStructureAvailable(cybFactory, me))
{ {
var cyblist = enumStruct(me, cybFactory); var cybcount = countStruct(cybFactory);
if (cyblist.length == 0 && playerPower(me) > 250 && grabTrucksAndBuild(20, cybFactory, 1)) if (cybcount == 0 && playerPower(me) > 250 && grabTrucksAndBuild(20, cybFactory, 1))
{ {
return; return;
} }
} }
// Build VTOL factory if we don't have one // Build VTOL factory if we don't have one
if (isStructureAvailable(me, vtolFactory)) if (isStructureAvailable(me, vtolFactory))
{ {
var vfaclist = enumStruct(me, vtolFactory); var vfaccount = countStruct(vtolFactory);
if (vfaclist.length == 0 && playerPower(me) > 500 && grabTrucksAndBuild(20, vtolFactory, 1)) if (vfaccount == 0 && playerPower(me) > 500 && grabTrucksAndBuild(20, vtolFactory, 1))
{ {
return; return;
} }
Expand Down Expand Up @@ -463,8 +460,7 @@ function eventDroidBuilt(droid, struct)
{ {
if (struct.stattype == FACTORY) if (struct.stattype == FACTORY)
{ {
var trucklist = enumDroid(me, DROID_CONSTRUCT); if (countDroid(DROID_CONSTRUCT) < 6)
if (trucklist.length < 6)
{ {
buildTruck(struct); buildTruck(struct);
} }
Expand Down Expand Up @@ -595,17 +591,6 @@ function eventStartLevel()


// Maintenance calls - to fix quirks // Maintenance calls - to fix quirks
setTimer("maintenance", 1000 * 60 * 2); // every 2 minutes, call it to check if anything left to do 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) function eventDroidIdle(droid)
Expand Down
4 changes: 2 additions & 2 deletions macosx/configs/fetchscripts/SetupPrebuiltComponents-Docs.sh
Original file line number Original file line Diff line number Diff line change
@@ -1,10 +1,10 @@
#!/bin/sh #!/bin/sh


OutDir="WarzoneHelp" OutDir="WarzoneHelp"
DirectorY="${OutDir}-a9c2db1" DirectorY="${OutDir}-5997d95"
FileName="${DirectorY}.tgz" FileName="${DirectorY}.tgz"
BuiltDLP="http://downloads.sourceforge.net/project/warzone2100/build-tools/mac/${FileName}" BuiltDLP="http://downloads.sourceforge.net/project/warzone2100/build-tools/mac/${FileName}"
MD5Sum="591d5dc15c4e56a61eb8e4433de31a8d" MD5Sum="72c0fd20b480892b6bcd9d9c31810491"


configs/FetchPrebuilt.sh "${DirectorY}" "${OutDir}" "${FileName}" "${BuiltDLP}" "${MD5Sum}" configs/FetchPrebuilt.sh "${DirectorY}" "${OutDir}" "${FileName}" "${BuiltDLP}" "${MD5Sum}"
exit ${?} exit ${?}
2 changes: 1 addition & 1 deletion src/droiddef.h
Original file line number Original file line Diff line number Diff line change
Expand Up @@ -76,7 +76,7 @@ enum DROID_TYPE
DROID_CYBORG_REPAIR, ///< cyborg repair droid - new for update 28/5/99 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_CYBORG_SUPER, ///< cyborg repair droid - new for update 7/6/99
DROID_SUPERTRANSPORTER, ///< SuperTransport (MP) DROID_SUPERTRANSPORTER, ///< SuperTransport (MP)
DROID_ANY, ///< Any droid. Only used as a parameter for intGotoNextDroidType(DROID_TYPE). DROID_ANY, ///< Any droid
}; };


struct COMPONENT struct COMPONENT
Expand Down
2 changes: 0 additions & 2 deletions src/game.cpp
Original file line number Original file line Diff line number Diff line change
Expand Up @@ -4808,7 +4808,6 @@ static bool loadSaveStructure2(const char *pFileName, STRUCTURE **ppList)
psFactory->buildPointsRemaining = ini.value("Factory/buildPointsRemaining", psFactory->buildPointsRemaining).toInt(); psFactory->buildPointsRemaining = ini.value("Factory/buildPointsRemaining", psFactory->buildPointsRemaining).toInt();
psFactory->timeStartHold = ini.value("Factory/timeStartHold", psFactory->timeStartHold).toInt(); psFactory->timeStartHold = ini.value("Factory/timeStartHold", psFactory->timeStartHold).toInt();
psFactory->loopsPerformed = ini.value("Factory/loopsPerformed", psFactory->loopsPerformed).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. // statusPending and pendingCount belong to the GUI, not the game state.
psFactory->secondaryOrder = ini.value("Factory/secondaryOrder", psFactory->secondaryOrder).toInt(); psFactory->secondaryOrder = ini.value("Factory/secondaryOrder", psFactory->secondaryOrder).toInt();
//adjust the module structures IMD //adjust the module structures IMD
Expand Down Expand Up @@ -5084,7 +5083,6 @@ bool writeStructFile(const char *pFileName)
ini.setValue("Factory/buildPointsRemaining", psFactory->buildPointsRemaining); ini.setValue("Factory/buildPointsRemaining", psFactory->buildPointsRemaining);
ini.setValue("Factory/timeStartHold", psFactory->timeStartHold); ini.setValue("Factory/timeStartHold", psFactory->timeStartHold);
ini.setValue("Factory/loopsPerformed", psFactory->loopsPerformed); ini.setValue("Factory/loopsPerformed", psFactory->loopsPerformed);
ini.setValue("Factory/productionOutput", psFactory->productionOutput);
// statusPending and pendingCount belong to the GUI, not the game state. // statusPending and pendingCount belong to the GUI, not the game state.
ini.setValue("Factory/secondaryOrder", psFactory->secondaryOrder); ini.setValue("Factory/secondaryOrder", psFactory->secondaryOrder);


Expand Down
69 changes: 64 additions & 5 deletions src/qtscriptfuncs.cpp
Original file line number Original file line Diff line number Diff line change
Expand Up @@ -53,6 +53,9 @@
#include "scriptextern.h" #include "scriptextern.h"


#define FAKE_REF_LASSAT 999 #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! // 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 // TODO, move this stuff into a script common subsystem
Expand Down Expand Up @@ -1964,13 +1967,15 @@ static QScriptValue js_getStructureLimit(QScriptContext *context, QScriptEngine
return QScriptValue(asStructLimits[player][index].limit); return QScriptValue(asStructLimits[player][index].limit);
} }


//-- \subsection{getStructureCount(structure type[, player])} //-- \subsection{countStruct(structure type[, player])}
//-- Create a structure on the given position. Returns true on success. //-- Count the number of structures of a given type.
static QScriptValue js_getStructureCount(QScriptContext *context, QScriptEngine *engine) //-- 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(); QString building = context->argument(0).toString();
int index = getStructStatFromName(building.toUtf8().constData()); int index = getStructStatFromName(building.toUtf8().constData());
int player; int player;
int quantity = 0;
if (context->argumentCount() > 1) if (context->argumentCount() > 1)
{ {
player = context->argument(1).toInt32(); player = context->argument(1).toInt32();
Expand All @@ -1980,7 +1985,56 @@ static QScriptValue js_getStructureCount(QScriptContext *context, QScriptEngine
player = engine->globalObject().property("me").toInt32(); player = engine->globalObject().property("me").toInt32();
} }
SCRIPT_ASSERT(context, index < numStructureStats && index >= 0, "Structure %s not found", building.toUtf8().constData()); 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)} //-- \subsection{setNoGoArea(x1, y1, x2, y2, player)}
Expand Down Expand Up @@ -2189,7 +2243,8 @@ bool registerFunctions(QScriptEngine *engine)
engine->globalObject().setProperty("setScrollParams", engine->newFunction(js_setScrollParams)); engine->globalObject().setProperty("setScrollParams", engine->newFunction(js_setScrollParams));
engine->globalObject().setProperty("addStructure", engine->newFunction(js_addStructure)); engine->globalObject().setProperty("addStructure", engine->newFunction(js_addStructure));
engine->globalObject().setProperty("getStructureLimit", engine->newFunction(js_getStructureLimit)); 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("loadLevel", engine->newFunction(js_loadLevel));
engine->globalObject().setProperty("setDroidExperience", engine->newFunction(js_setDroidExperience)); engine->globalObject().setProperty("setDroidExperience", engine->newFunction(js_setDroidExperience));
engine->globalObject().setProperty("setNoGoArea", engine->newFunction(js_setNoGoArea)); engine->globalObject().setProperty("setNoGoArea", engine->newFunction(js_setNoGoArea));
Expand Down Expand Up @@ -2232,6 +2287,7 @@ bool registerFunctions(QScriptEngine *engine)
engine->globalObject().setProperty("DROID_TRANSPORTER", DROID_TRANSPORTER, QScriptValue::ReadOnly | QScriptValue::Undeletable); 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_SUPERTRANSPORTER", DROID_SUPERTRANSPORTER, QScriptValue::ReadOnly | QScriptValue::Undeletable);
engine->globalObject().setProperty("DROID_COMMAND", DROID_COMMAND, 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("HQ", REF_HQ, QScriptValue::ReadOnly | QScriptValue::Undeletable);
engine->globalObject().setProperty("FACTORY", REF_FACTORY, 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); engine->globalObject().setProperty("POWER_GEN", REF_POWER_GEN, QScriptValue::ReadOnly | QScriptValue::Undeletable);
Expand All @@ -2254,6 +2310,9 @@ bool registerFunctions(QScriptEngine *engine)
engine->globalObject().setProperty("STRUCTURE", OBJ_STRUCTURE, QScriptValue::ReadOnly | QScriptValue::Undeletable); engine->globalObject().setProperty("STRUCTURE", OBJ_STRUCTURE, QScriptValue::ReadOnly | QScriptValue::Undeletable);
engine->globalObject().setProperty("DROID", OBJ_DROID, 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("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("POSITION", SCRIPT_POSITION, QScriptValue::ReadOnly | QScriptValue::Undeletable);
engine->globalObject().setProperty("AREA", SCRIPT_AREA, 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); engine->globalObject().setProperty("PLAYER_DATA", SCRIPT_PLAYER, QScriptValue::ReadOnly | QScriptValue::Undeletable);
Expand Down

0 comments on commit 584fb55

Please sign in to comment.