qt branch: Kill off the over-engineered tagfile format. Replacing it with the more retro ini file format.

master
Per Inge Mathisen 2011-04-06 22:06:17 +02:00
parent 1ada89fb66
commit df4e48ec16
19 changed files with 161 additions and 2080 deletions

View File

@ -26,7 +26,6 @@ BASELIST = \
shaders\
stats \
structs \
tagdefinitions \
texpages \
tileset \
wrf

View File

@ -8,7 +8,7 @@ const buggy = "BarbarianBuggy";
const bloke = "BaBaPeople";
const jeep = "BabaJeep";
const firetruck = "BabaFireTruck";
const cannonbus = "BabaBusCan"
const cannonbus = "BabaBusCan";
const firebus = "BabaFireCan";
// scav group

View File

@ -1,27 +0,0 @@
#
# FORMAT: tag enum, value representation (VR), value multiplicity (VM), default value
# VR: ST for text, US for unsigned, SI for signed, FP for floating point, GR for group,
# EN for group end, BO for boolean
# VM: Must be no longer than the size given here; set to 00 for repeating groups
# default value cannot be set for VM > 1, ST, GR or EN
#
01 ST 12 - # Format identifier: "FXData"
02 GR 00 - # EFFECTS GROUP
01 US 01 - # control
02 US 01 - # group
03 US 01 - # type
04 US 01 - # frameNumber
05 US 01 - # size
06 US 01 - # baseScale
07 US 01 - # specific
08 FP 03 - # Position vector
09 FP 03 - # Velocity vector
0A SI 03 - # Rotation vector
0B SI 03 - # Spin vector
0C US 01 - # birthTime
0D US 01 - # lastFrame
0E US 01 - # frameDelay
0F US 01 - # lifeSpan
10 US 01 - # radius
11 ST 00 - # IMD file name
FF EN 00 -

View File

@ -1,28 +0,0 @@
#
# FORMAT: tag enum, value representation (VR), value multiplicity (VM), default value
# VR: ST for text, US for unsigned, SI for signed, FP for floating point, GR for group,
# EN for group end, BO for boolean
# VM: Must be no longer than the size given here; set to 00 for repeating groups
# default value cannot be set for VM > 1, ST, GR or EN
#
01 ST 12 - # Format identifier: "WZTAGFILE1"
02 GR 00 - # DROID GROUP
01 US 01 - # Droid ID
02 US 03 - # Droid position in (x,y,z) coordinates
03 FP 01 - # RETIRED (had unknown usage)
04 FP 03 - # RETIRED (had unknown usage)
05 US 500 - # Long unsigned byte array
06 US 500 - # Long unsigned byte array
09 GR 00 - # Droid weapon group
01 US 01 - # Weapon type
02 US 01 10 # Ammo left
03 US 01 0 # Time last fired
04 US 01 0 # Recoil value
05 SI 03 - # Array of signed int
FF EN 00 -
FF EN 00 -
03 GR 00 - # STRUCTURE GROUP
01 US 01 - # Structure ID
02 US 03 - # Structure position in (x,y,z) coordinates
FF EN 00 -
04 US 01 09 # Some default value of 9

View File

@ -1,215 +0,0 @@
#
# FORMAT: tag enum, value representation (VR), value multiplicity (VM), default value
# VR: ST for text, US for unsigned, SI for signed, FP for floating point, GR for group,
# EN for group end, BO for boolean
# VM: Must be no longer than the size given here; set to 00 for repeating groups
# default value cannot be set for VM > 1, ST, GR or EN
#
01 ST 01 - # Format identifier: "WZTAGFILE1"
03 GR 01 - # MAP INFO GROUP
01 US 01 64 # Map width
02 US 01 64 # Map height
FF EN 00 -
04 GR 01 - # CAMERA INFO GROUP
01 FP 03 - # Camera position
02 FP 03 - # Camera rotation
FF EN 00 -
05 GR 00 - # TEXTURE GROUP
01 ST 80 - # Texture name
FF EN 00 -
0a GR 00 - # TILE GROUP
01 US 01 0 # Terrain type
02 US 01 0 # Texture number
03 US 01 0 # Triangle flip
04 US 01 0 # Texture x flip
05 US 01 0 # Texture y flip
06 US 01 0 # Not blocking (even if structure or feature on it)
07 US 01 0 # *RETIRED* Do not draw flag
08 US 01 0 # Height of first corner
09 US 01 0 # Visibility bits
0a US 01 0 # Info bits
0b US 01 0 # Rotation
FF EN 00 -
0b GR 00 - # GATEWAY GROUP
01 US 04 - # (x1, y1, x2, y2) coordinates
FF EN 00 -
0c GR 00 - # TEXTURE <=> TERRAIN TYPE MAPPING GROUP
01 US 01 0 # The terrain type of this texture
FF EN 00 -
0d GR 00 - # PLAYER INFO GROUP
01 GR 00 - # RESEARCH GROUP
01 US 01 1 # Is research possible of this tech?
02 US 01 0 # Research status
03 US 01 0 # Current research points
FF EN 00 -
02 GR 00 - # STRUCTURE LIMITS GROUP
01 ST 80 - # Name of structure
02 US 01 255 # Limit
FF EN 00 -
03 GR 00 - # FLAGS GROUP
01 US 01 - # Type
02 US 01 0 # Frame number last drawn
03 US 03 - # Screen coordinates and radius (x, y, r)
04 US 04 - # Player that the position belongs to
05 BO 05 0 # Is position selected by the player?
06 US 03 - # World coordinates (x, y, z)
07 US 01 0 # Factory index
08 US 01 0 # Factory type
09 US 01 - # Repair ID - only set if factory type is REPAIR_FLAG
0a BO 01 0 # Do not register flag in flag list (commanders)
FF EN 00 -
04 GR 00 - # MESSAGE GROUP
01 SI 01 -1 # Object ID, if set, use it rather than name below; -1 means unset
02 ST 80 - # Name
03 BO 01 0 # Is message read?
FF EN 00 -
FF EN 00 -
0e GR 00 - # PRODUCTION RUNS GROUP (factory types)
01 GR 00 - # Number of factories
01 GR 00 - # Production runs for each factory
01 US 01 0 # Quantity
02 US 01 0 # Built
03 SI 01 -1 # Template multiplayerID, -1 if none
FF EN 00 -
FF EN 00 -
FF EN 00 -
0f GR 00 - # OBJECT GROUP
01 GR 00 - # BASE OBJECT GROUP
01 US 01 - # Object type (always type droid)
02 US 01 - # Unique object id
03 US 03 - # (x, y, z) position coordinates
04 FP 01 - # Direction
05 SI 01 - # Pitch
06 SI 01 - # Roll
07 US 01 - # Player
08 US 01 - # Selection group
09 US 01 - # Selected
0a US 01 - # Cluster
0b US 08 - # Visibility per player
0c US 01 - # Died (in game time)
0d US 01 - # Last smoke emission (in game time)
0e BO 01 - # On fire?
0f US 01 - # Burn start (in game time)
10 US 01 - # Total accumulated burn damage
FF EN 00 -
02 GR 00 - # SENSOR GROUP
01 US 01 0 # Sensor range
02 US 01 0 # Sensor power
03 US 01 0 # ECM range
04 US 01 0 # ECM power
FF EN 00 -
03 GR 00 - # OBJECT STAT GROUP
01 US 01 - # Original body points
02 US 01 2 # Number of weapon classes
03 GR 00 - # ARMOUR GROUP (for each defined side)
01 US 01 0 # Armour vs kinetic weapons
02 US 02 0 # Armour vs heat weapons
FF EN 00 -
04 US 01 - # Resistance (used in electronic warfare)
FF EN 00 -
04 GR 00 - # WEAPON GROUP
01 US 01 - # Weapon type
02 US 01 0 # Weapon rotation
03 US 01 0 # Weapon pitch
04 US 01 0 # hitPoints REMOVED
05 US 01 0 # Ammo
06 US 01 0 # Time frame it was last fired
07 US 01 0 # recoilValue (EXPLAIN ME)
08 SI 01 -1 # ID of weapon target, -1 if none
FF EN 00 -
0a GR 00 - # DROID GROUP
01 US 01 - # Droid type
02 US 0a - # Components
03 BO 01 0 # Transport on mission?
07 US 01 - # Weight
08 US 01 - # Base speed
09 ST 60 - # Droid name (typically template name)
0a US 01 - # Current body points
0b FP 01 - # Experience
0c US 01 - # Name version (EXPLAIN ME)
0e SI 01 -1 # Current job target ID (repairing stuff etc)
0f SI 01 -1 # Current stats target ID (building stuff etc)
10 SI 01 -1 # Current base target ID (rearm pad etc)
11 US 01 0 # Current order
12 US 04 - # Current order parameters
13 GR 00 - # DROID ORDER GROUP (queued orders)
01 US 01 - # Order
02 US 04 - # Order parameters
FF EN 00 -
14 SI 01 0 # Formation direction
15 SI 01 0 # Formation X
16 SI 01 0 # Formation Y
17 US 03 - # VTOL ammo (for each weapon)
18 SI 02 - # Droid movement final destination (x, y)
19 SI 02 - # Droid movement origin (x, y)
1a SI 02 - # Droid movement immediate target (x, y)
1b FP 03 - # Fractions of x,y,z
1c FP 01 - # Droid speed
1d SI 02 - # Vector for the end of path boundary (x, y)
1e US 02 - # Position of last bump (x, y)
1f SI 01 - # Direction of motion (not the direction the droid is facing)
20 SI 01 - # Direction at last bump
21 US 01 - # Time of first bump with something
22 US 01 - # Time of last bump with a droid - relative to bumpTime
23 US 01 - # When MOVEPAUSE started - relative to bumpTime
24 US 01 - # VTOL movement speed
25 GR 00 - # PATH GROUP (each item is a position in a path)
01 US 01 - # (x, y) position node
FF EN 00 -
26 US 01 0 # Path status
27 US 01 0 # Current position in path
FF EN 00 -
0b GR 00 - # STRUCTURE GROUP (EXPLAIN ME)
01 US 01 - # Structure type
02 SI 01 0 # currentPowerAccrued
03 US 01 0 # lastResistance
04 US 01 0 # targetted
05 US 01 0 # timeLastHit
06 US 01 0 # lastHitWeapon
07 US 01 1 # status (0 = being built, 1 = built, 2 = being demolished)
08 SI 01 0 # currentBuildPts
FF EN 00 -
0c GR 00 - # FEATURE GROUP
01 US 01 0 # Time frame it was created
FF EN 00 -
0d GR 00 - # FACTORY GROUP
01 US 01 0 # Capacity (the max size of body the factory can produce)
02 US 01 0 # Quantity (the number of droids to produce OR for selectedPlayer, how many loops to perform)
03 US 01 0 # Loops performed
04 US 01 0 # Production output (droid build points produced per build cycle)
05 US 01 0 # powerAccrued (used to keep track of power before building a droid)
06 SI 01 -1 # ID of template used, -1 for none
07 US 01 0 # timeStarted
08 US 01 0 # timeToBuild
09 US 01 0 # timeStartHold
0a US 01 0 # secondaryOrder
0b SI 01 -1 # Factory number, also used to find right flag after game load, oddly enough; -1 for none
0c SI 01 -1 # Commander ID, if any, -1 if none
FF EN 00 -
0e GR 00 - # RESEARCH GROUP
01 US 01 0 # Number of upgrades it has
02 US 01 0 # powerAccrued
03 US 01 0 # timeStartHold
04 US 01 0 # ID of research target
05 US 01 0 # Time frame research started
FF EN 00 -
0f GR 00 - # RESOURCE EXTRACTOR GROUP
01 US 01 0 # Maximum amount of power that can be extracted from this resource
02 SI 01 -1 # ID of power plant that owns this resource, if any, -1 if none
FF EN 00 -
10 GR 00 - # POWER PLANT GROUP
01 US 01 0 # Number of upgrades it has
FF EN 00 -
11 GR 00 - # REPAIR FACILITY GROUP
01 US 01 0 # timeStarted
02 US 01 0 # powerAccrued
03 SI 01 -1 # Object being repaired, if any, -1 if none
04 SI 01 -1 # Research facility number, also used to find right flag after game load, -1 for none
FF EN 00 -
12 GR 00 - # REARM PAD GROUP
01 US 01 0 # reArmPoints
02 US 01 0 # timeStarted
03 US 01 0 # currentPtsAdded
04 SI 01 -1 # Object being rearmed, if any, -1 if none
FF EN 00 -
FF EN 00 -

View File

@ -1,19 +0,0 @@
#
# FORMAT: tag enum, value representation (VR), value multiplicity (VM), default value
# VR: ST for text, US for unsigned, SI for signed, FP for floating point, GR for group,
# EN for group end, BO for boolean
# VM: Must be no longer than the size given here; set to 00 for repeating groups
# default value cannot be set for VM > 1, ST, GR or EN
#
01 ST 12 - # Format identifier: "ScoreData"
02 US 01 - # units built
03 US 01 - # units killed
04 US 01 - # units lost
05 US 01 - # structures built
06 US 01 - # structures killed
07 US 01 - # structures lost
08 US 01 - # artifacts found
09 US 01 - # mission started
0A US 01 - # shots on target
0B US 01 - # shots off target
0C US 01 - # babas mowed down

View File

@ -1,37 +0,0 @@
#
# FORMAT: tag enum, value representation (VR), value multiplicity (VM), default value
# VR: ST for text, US for unsigned, SI for signed, FP for floating point, GR for group,
# EN for group end, BO for boolean
# VM: Must be no longer than the size given here; set to 00 for repeating groups
# default value cannot be set for VM > 1, ST, GR or EN
#
01 ST 12 - # Format identifier: "WZTAGFILE1"
02 GR 00 - # DROID GROUP
01 US 01 - # Droid ID
02 US 03 - # Droid position in (x,y,z) coordinates
03 FP 01 - # RETIRED (had unknown usage)
04 FP 03 - # RETIRED (had unknown usage)
05 US 500 - # Long unsigned byte array
06 US 500 - # Long unsigned byte array
07 GR 00 - # Write-only group
01 US 01 0 # Simple value
02 US 01 0 # Simple value
03 GR 00 - # Another nested group
01 US 01 0 # Default value
FF EN 00 -
FF EN 00 -
08 GR 00 - # Empty group
FF EN 00 -
09 GR 00 - # Droid weapon group
01 US 01 - # Weapon type
02 US 01 10 # Ammo left
03 US 01 0 # Time last fired
04 US 01 0 # Recoil value
05 SI 03 - # Array of signed int
FF EN 00 -
FF EN 00 -
03 GR 00 - # STRUCTURE GROUP
01 US 01 - # Structure ID
02 US 03 - # Structure position in (x,y,z) coordinates
FF EN 00 -
04 US 01 9 # Some default value of 9

View File

@ -1,14 +0,0 @@
#
# FORMAT: tag enum, value representation (VR), value multiplicity (VM), default value
# VR: ST for text, US for unsigned, SI for signed, FP for floating point, GR for group,
# EN for group end, BO for boolean
# VM: Must be no longer than the size given here; set to 00 for repeating groups
# default value cannot be set for VM > 1, ST, GR or EN
#
01 US 01 1
02 SI 01 2
03 FP 01 3
04 US 01 4
05 SI 01 5
06 ST 80 -
07 BO 01 1

View File

@ -65,7 +65,6 @@ noinst_HEADERS = \
string_ext.h \
strres.h \
strresly.h \
tagfile.h \
treap.h \
trig.h \
types.h \
@ -100,7 +99,6 @@ libframework_a_SOURCES = \
SDL_framerate.cpp \
stdio_ext.cpp \
strres.cpp \
tagfile.cpp \
treap.cpp \
trig.cpp \
utf.cpp

File diff suppressed because it is too large Load Diff

View File

@ -1,102 +0,0 @@
// Written by Per I Mathisen, 2007
// Released into the public domain, no rights reserved.
//
// The tagfile format is portable, nested, tagged binary format that should be
// useful for storing information that needs to be accessible several years
// into the future. That is, it is an easily extensible binary format, a feature
// usually reserved for text based formats. It also uses default values to
// reduce space, and despite its tagged nature, it consumes only a minimal overhead
// through the use a well-defined protocol file that is loaded separately.
//
// Each user of this code should define a protocol that is henceforth called
// the defined format. This consists of a series of tags that may contain either
// information or new tag groups. The tag groups can be nested until you run out
// of memory. Each tag group has its own namespace of tags. Each tag has a defined
// value representation (VR), a defined value multiplicity (VM), and an optional
// default value.
//
// Tags that have the default value may be omitted, and the read code will simply
// insert the default value when the tag is read. A group must be present in order
// for the read code to enter it even if all tags inside have default values.
//
// Each group can contain multiple instances of the same tag set. These are
// separated by separator tags. You can have any number of instances in a group,
// but you must know the number of instances beforehand.
//
// When reading and writing tags, remember to ALWAYS do so with successively
// increasing tag value. Do not write tag number 3 before tag number 1.
//
// See the included defined format files for more information on how to write them.
#ifndef _tagfile_h
#define _tagfile_h
#include "lib/framework/types.h"
typedef uint8_t element_t;
/** Open definition file and data file; return true if successful. */
bool tagOpenWrite(const char *definition, const char *datafile);
/** Open definition file and data file; return true if successful. */
bool tagOpenRead(const char *definition, const char *datafile);
/** Clean up and close the tagfile system down. */
void tagClose(void);
/** Report last error, then zeroes the internal error variable. If it
* returns false, there is no error. */
bool tagGetError(void);
/** Built-in unit test. */
void tagTest(void);
/*** tagWrite ***/
/** Enter a group given by tag which contains the given number of elements. */
bool tagWriteEnter(element_t tag, uint16_t elements);
/** Leave the given group. The group is given for consistency checking only. */
bool tagWriteLeave(element_t tag);
/** Start writing a new instance of a group. */
bool tagWriteNext(void);
/* Write methods */
bool tagWrite(element_t tag, uint32_t val);
bool tagWrites(element_t tag, int32_t val);
bool tagWritef(element_t tag, float val);
bool tagWritefv(element_t tag, uint16_t count, const float *vals);
bool tagWrite8v(element_t tag, uint16_t count, const uint8_t *vals);
bool tagWrite16v(element_t tag, uint16_t count, const uint16_t *vals);
bool tagWrites32v(element_t tag, uint16_t count, const int32_t *vals);
bool tagWriteString(element_t tag, const char *string);
bool tagWriteBool(element_t tag, bool val);
/*** tagread ***/
/** Enter a group given by tag and return the number of elements in it. */
uint16_t tagReadEnter(element_t tag);
/** Leave the given group. The group is given for consistency checking only. */
void tagReadLeave(element_t tag);
/** Start reading a new instance of a group. Returns false if no more entities
* to read, which can be used for iteration, if desired. */
bool tagReadNext(void);
/* Read methods */
uint32_t tagRead(element_t tag);
int32_t tagReads(element_t tag);
bool tagReadBool(element_t tag);
float tagReadf(element_t tag);
bool tagReadfv(element_t tag, uint16_t size, float *vals);
uint8_t *tagRead8vDup(element_t tag, int *size);
bool tagRead8v(element_t tag, uint16_t size, uint8_t *vals);
bool tagRead16v(element_t tag, uint16_t size, uint16_t *vals);
bool tagReads16v(element_t tag, uint16_t size, int16_t *vals);
bool tagReads32v(element_t tag, uint16_t size, int32_t *vals);
bool tagReadString(element_t tag, uint16_t size, char *buffer);
char *tagReadStringDup(element_t tag);
#endif

View File

@ -56,6 +56,7 @@ struct Vector3f
Vector3f() {}
Vector3f(float x, float y, float z) : x(x), y(y), z(z) {}
Vector3f(Vector3i const &v) : x(v.x), y(v.y), z(v.z) {}
Vector3f(Vector3f const &v) : x(v.x), y(v.y), z(v.z) {}
Vector3f(Vector2f const &xy, int z) : x(xy.x), y(xy.y), z(z) {}
float x, y, z;

View File

@ -1317,3 +1317,45 @@ static int WZkeyToQtKey(int code)
return 0; // nothing found (should never happen)
}
void WzConfig::setVector3f(const QString &name, const Vector3f &v)
{
QStringList l;
l.push_back(QString::number(v.x));
l.push_back(QString::number(v.y));
l.push_back(QString::number(v.z));
setValue(name, l);
}
Vector3f WzConfig::vector3f(const QString &name)
{
Vector3f r;
ASSERT_OR_RETURN(r, contains(name), "Missing %s", name.toUtf8().constData());
QList<QVariant> v = value(name).toList();
ASSERT(v.size() == 3, "Bad list of %s", name.toUtf8().constData());
r.x = v[0].toDouble();
r.y = v[1].toDouble();
r.z = v[2].toDouble();
return r;
}
void WzConfig::setVector3i(const QString &name, const Vector3i &v)
{
QStringList l;
l.push_back(QString::number(v.x));
l.push_back(QString::number(v.y));
l.push_back(QString::number(v.z));
setValue(name, l);
}
Vector3i WzConfig::vector3i(const QString &name)
{
Vector3i r;
ASSERT_OR_RETURN(r, contains(name), "Missing %s", name.toUtf8().constData());
QList<QVariant> v = value(name).toList();
ASSERT(v.size() == 3, "Bad list of %s", name.toUtf8().constData());
r.x = v[0].toInt();
r.y = v[1].toInt();
r.z = v[2].toInt();
return r;
}

View File

@ -42,6 +42,10 @@ class WzConfig : public QSettings
{
public:
WzConfig(const QString &name, QObject *parent = 0) : QSettings(QString("wz::") + name, QSettings::IniFormat, parent) {}
Vector3f vector3f(const QString &name);
void setVector3f(const QString &name, const Vector3f &v);
Vector3i vector3i(const QString &name);
void setVector3i(const QString &name, const Vector3i &v);
};
class WzMainWindow : public QGLWidget

View File

@ -35,10 +35,9 @@
* STILL NEED TO REMOVE SOME MAGIC NUMBERS INTO #DEFINES!!! *
************************************************************
*/
#include "lib/framework/frame.h"
#include "lib/framework/wzapp.h"
#include "lib/framework/frameresource.h"
#include "lib/framework/input.h"
#include "lib/framework/tagfile.h"
#include "lib/framework/math_ext.h"
#include "lib/ivis_opengl/ivisdef.h" //ivis matrix code
@ -2537,134 +2536,98 @@ void effectResetUpdates(void)
}
static const char FXData_tag_definition[] = "tagdefinitions/savegame/effects.def";
static const char FXData_file_identifier[] = "FXData";
/** This will save out the effects data */
bool writeFXData(const char* fileName)
bool writeFXData(const char *fileName)
{
EFFECT *it;
int i = 0;
if (!tagOpenWrite(FXData_tag_definition, fileName))
WzConfig ini(fileName);
if (ini.status() != QSettings::NoError)
{
ASSERT(false, "writeFXData: error while opening file (%s)", fileName);
debug(LOG_ERROR, "Could not open %s", fileName);
return false;
}
tagWriteString(0x01, FXData_file_identifier);
// Enter effects group and dump all active EFFECTs
tagWriteEnter(0x02, activeList.num);
for (it = activeList.first; it != NULL; it = it->next)
for (it = activeList.first; it != NULL; it = it->next, i++)
{
tagWrite(0x01, it->control);
tagWrite(0x02, it->group);
tagWrite(0x03, it->type);
tagWrite(0x04, it->frameNumber);
tagWrite(0x05, it->size);
tagWrite(0x06, it->baseScale);
tagWrite(0x07, it->specific);
ini.beginGroup("effect_" + QString::number(i));
ini.setValue("control", it->control);
ini.setValue("group", it->group);
ini.setValue("type", it->type);
ini.setValue("frameNumber", it->frameNumber);
ini.setValue("size", it->size);
ini.setValue("baseScale", it->baseScale);
ini.setValue("specific", it->specific);
ini.setVector3f("position", it->position);
ini.setVector3f("velocity", it->velocity);
ini.setVector3i("rotation", it->rotation);
ini.setVector3i("spin", it->spin);
ini.setValue("birthTime", it->birthTime);
ini.setValue("lastFrame", it->lastFrame);
ini.setValue("frameDelay", it->frameDelay);
ini.setValue("lifeSpan", it->lifeSpan);
ini.setValue("radius", it->radius);
tagWritefv (0x08, 3, &it->position.x);
tagWritefv (0x09, 3, &it->velocity.x);
tagWrites32v (0x0A, 3, &it->rotation.x);
tagWrites32v (0x0B, 3, &it->spin.x);
const char *imd_name = resGetNamefromData("IMD", it->imd);
if (imd_name)
{
ini.setValue("imd_name", imd_name);
}
tagWrite(0x0C, it->birthTime);
tagWrite(0x0D, it->lastFrame);
tagWrite(0x0E, it->frameDelay);
tagWrite(0x0F, it->lifeSpan);
tagWrite(0x10, it->radius);
tagWriteString(0x11, resGetNamefromData("IMD", it->imd));
// Move on to reading the next effect group
tagWriteNext();
// Move on to reading the next effect
ini.endGroup();
}
// Leave the effects group again...
tagWriteLeave(0x02);
// Close the file
tagClose();
// Everything is just fine!
return true;
}
/** This will read in the effects data */
bool readFXData(const char* fileName)
bool readFXData(const char *fileName)
{
unsigned int count, i;
char strbuffer[25];
if (!tagOpenRead(FXData_tag_definition, fileName))
{
debug(LOG_ERROR, "readFXData: error while opening file (%s)", fileName);
return false;
}
// Read & verify the format header identifier
tagReadString(0x01, sizeof(strbuffer), strbuffer);
if (strncmp(strbuffer, FXData_file_identifier, sizeof(strbuffer)) != 0)
{
debug(LOG_ERROR, "readFXData: Weird file type found (in file %s)? Has header string: %s", fileName, strbuffer);
return false;
}
// Clear out anything that's there already!
initEffectsSystem();
// Enter effects group and load all EFFECTs
count = tagReadEnter(0x02);
for(i = 0; i < count; ++i)
WzConfig ini(fileName);
if (ini.status() != QSettings::NoError)
{
char imd_name[PATH_MAX];
debug(LOG_ERROR, "Could not open %s", fileName);
return false;
}
QStringList list = ini.childGroups();
for (int i = 0; i < list.size(); ++i)
{
ini.beginGroup(list[i]);
EFFECT *curEffect = Effect_malloc();
/* Deal with out-of-memory conditions */
if (curEffect == NULL) {
debug(LOG_ERROR, "Out of memory");
return false;
}
curEffect->control = tagRead(0x01);
curEffect->group = (EFFECT_GROUP)tagRead(0x02);
curEffect->type = (EFFECT_TYPE)tagRead(0x03);
curEffect->frameNumber = tagRead(0x04);
curEffect->size = tagRead(0x05);
curEffect->baseScale = tagRead(0x06);
curEffect->specific = tagRead(0x07);
tagReadfv (0x08, 3, &curEffect->position.x);
tagReadfv (0x09, 3, &curEffect->velocity.x);
tagReads32v (0x0A, 3, &curEffect->rotation.x);
tagReads32v (0x0B, 3, &curEffect->spin.x);
curEffect->birthTime = tagRead(0x0C);
curEffect->lastFrame = tagRead(0x0D);
curEffect->frameDelay = tagRead(0x0E);
curEffect->lifeSpan = tagRead(0x0F);
curEffect->radius = tagRead(0x10);
tagReadString(0x11, sizeof(imd_name), imd_name);
if (imd_name[0] != '\0')
curEffect->control = ini.value("control").toInt();
curEffect->group = (EFFECT_GROUP)ini.value("group").toInt();
curEffect->type = (EFFECT_TYPE)ini.value("type").toInt();
curEffect->frameNumber = ini.value("control").toInt();
curEffect->size = ini.value("control").toInt();
curEffect->baseScale = ini.value("control").toInt();
curEffect->specific = ini.value("control").toInt();
curEffect->position = ini.vector3f("position");
curEffect->velocity = ini.vector3f("velocity");
curEffect->rotation = ini.vector3i("rotation");
curEffect->spin = ini.vector3i("spin");
curEffect->birthTime = ini.value("control").toInt();
curEffect->lastFrame = ini.value("control").toInt();
curEffect->frameDelay = ini.value("control").toInt();
curEffect->lifeSpan = ini.value("control").toInt();
curEffect->radius = ini.value("control").toInt();
if (ini.contains("imd_name"))
{
curEffect->imd = (iIMDShape*)resGetData("IMD", imd_name);
curEffect->imd = (iIMDShape*)resGetData("IMD", ini.value("imd_name").toString().toUtf8().constData());
}
else
{
curEffect->imd = NULL;
}
// Move on to reading the next effect group
tagReadNext();
// Move on to reading the next effect
ini.endGroup();
}
// Leave the effects group again...
tagReadLeave(0x02);
// Close the file
tagClose();
/* Hopefully everything's just fine by now */
return true;

View File

@ -17,7 +17,7 @@
along with Warzone 2100; if not, write to the Free Software
Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
*/
#include "lib/framework/frame.h"
#include "lib/framework/wzapp.h"
/* Standard library headers */
#include <physfs.h>
@ -29,7 +29,6 @@
#include "lib/framework/frameint.h"
#include "lib/framework/physfs_ext.h"
#include "lib/framework/strres.h"
#include "lib/framework/tagfile.h"
#include "lib/gamelib/gtime.h"
#include "lib/ivis_opengl/ivisdef.h"
@ -2131,8 +2130,8 @@ static bool loadSaveStructLimits(char *pFileData, UDWORD filesize);
static bool loadSaveStructLimitsV(char *pFileData, UDWORD filesize, UDWORD numLimits);
static bool writeStructLimitsFile(char *pFileName);
static bool readFiresupportDesignators(char *pFileName);
static bool writeFiresupportDesignators(char *pFileName);
static bool readFiresupportDesignators(const char *pFileName);
static bool writeFiresupportDesignators(const char *pFileName);
static bool writeScriptState(char *pFileName);
@ -2809,7 +2808,7 @@ bool loadGame(const char *pGameToLoad, bool keepObjects, bool freeMem, bool User
{
//load in the message list file
aFileName[fileExten] = '\0';
strcat(aFileName, "fxstate.tag");
strcat(aFileName, "fxstate.ini");
// load the fx data from the file
if (!readFXData(aFileName))
@ -3126,7 +3125,7 @@ bool loadGame(const char *pGameToLoad, bool keepObjects, bool freeMem, bool User
{
//load in the message list file
aFileName[fileExten] = '\0';
strcat(aFileName, "score.tag");
strcat(aFileName, "score.ini");
// Load the fx data from the chosen file
if (!readScoreData(aFileName))
@ -3175,7 +3174,7 @@ bool loadGame(const char *pGameToLoad, bool keepObjects, bool freeMem, bool User
{
//load in the command list file
aFileName[fileExten] = '\0';
strcat(aFileName, "firesupport.tag");
strcat(aFileName, "firesupport.ini");
if (!readFiresupportDesignators(aFileName))
{
@ -3532,7 +3531,7 @@ bool saveGame(char *aFileName, GAME_TYPE saveType)
//create the message filename
CurrentFileName[fileExtension] = '\0';
strcat(CurrentFileName, "fxstate.tag");
strcat(CurrentFileName, "fxstate.ini");
/*Write the data to the file*/
if (!writeFXData(CurrentFileName))
{
@ -3543,7 +3542,7 @@ bool saveGame(char *aFileName, GAME_TYPE saveType)
//added at V15 save
//create the message filename
CurrentFileName[fileExtension] = '\0';
strcat(CurrentFileName, "score.tag");
strcat(CurrentFileName, "score.ini");
/*Write the data to the file*/
if (!writeScoreData(CurrentFileName))
{
@ -3563,7 +3562,7 @@ bool saveGame(char *aFileName, GAME_TYPE saveType)
//create the message filename
CurrentFileName[fileExtension] = '\0';
strcat(CurrentFileName, "firesupport.tag");
strcat(CurrentFileName, "firesupport.ini");
/*Write the data to the file*/
if (!writeFiresupportDesignators(CurrentFileName))
{
@ -9912,82 +9911,50 @@ bool writeStructLimitsFile(char *pFileName)
return false;
}
static const char FireSupport_tag_definition[] = "tagdefinitions/savegame/firesupport.def";
static const char FireSupport_file_identifier[] = "FIRESUPPORT";
/*!
* Load the current fire-support designated commanders (the one who has fire-support enabled)
*/
bool readFiresupportDesignators(char *pFileName)
bool readFiresupportDesignators(const char *pFileName)
{
unsigned int numPlayers, player;
char formatIdentifier[12] = "";
if (!tagOpenRead(FireSupport_tag_definition, pFileName))
WzConfig ini(pFileName);
if (ini.status() != QSettings::NoError)
{
debug(LOG_ERROR, "readFiresupportDesignators: Failed to open savegame %s", pFileName);
debug(LOG_ERROR, "Could not open %s", pFileName);
return false;
}
debug(LOG_MAP, "Reading tagged savegame %s with definition %s:", pFileName, FireSupport_tag_definition);
tagReadString(0x01, 12, formatIdentifier);
if (strcmp(formatIdentifier, FireSupport_file_identifier) != 0)
QStringList list = ini.childGroups();
for (int i = 0; i < list.size(); ++i)
{
debug(LOG_ERROR, "readFiresupportDesignators: Incompatble %s, 'FIRESUPPORT' expected", pFileName);
return false;
}
numPlayers = tagReadEnter(0x02);
for (player = 0; player < numPlayers; player++)
{
uint32_t id = tagRead(0x01);
uint32_t id = ini.value("Player_" + QString::number(i) + "/id", NULL_ID).toInt();
if (id != NULL_ID)
{
cmdDroidSetDesignator((DROID*)getBaseObjFromId(id));
}
tagReadNext();
}
tagReadLeave(0x02);
tagClose();
return true;
}
/*!
* Save the current fire-support designated commanders (the one who has fire-support enabled)
*/
bool writeFiresupportDesignators(char *pFileName)
bool writeFiresupportDesignators(const char *pFileName)
{
unsigned int player;
int player;
if (!tagOpenWrite(FireSupport_tag_definition, pFileName))
WzConfig ini(pFileName);
if (ini.status() != QSettings::NoError)
{
debug(LOG_ERROR, "writeFiresupportDesignators: Failed to create savegame %s", pFileName);
debug(LOG_ERROR, "Could not open %s", pFileName);
return false;
}
debug(LOG_MAP, "Creating tagged savegame %s with definition %s:", pFileName, FireSupport_tag_definition);
tagWriteString(0x01, FireSupport_file_identifier);
tagWriteEnter(0x02, MAX_PLAYERS);
for (player = 0; player < MAX_PLAYERS; player++)
{
DROID * psDroid = cmdDroidGetDesignator(player);
DROID *psDroid = cmdDroidGetDesignator(player);
if (psDroid != NULL)
{
tagWrite(0x01, psDroid->id);
ini.setValue("Player_" + QString::number(player) + "/id", psDroid->id);
}
else
{
tagWrite(0x01, NULL_ID);
}
tagWriteNext();
}
tagWriteLeave(0x02);
tagClose();
return true;
}

View File

@ -34,7 +34,6 @@
#include "lib/framework/configfile.h"
#include "lib/framework/input.h"
#include "lib/framework/physfs_ext.h"
#include "lib/framework/tagfile.h"
#include "lib/framework/wzapp_c.h"
#include "lib/exceptionhandler/exceptionhandler.h"
#include "lib/exceptionhandler/dumpinfo.h"
@ -1305,7 +1304,6 @@ int finalInitialization()
/* Runtime unit testing */
if (selfTest)
{
tagTest();
parseTest();
levTest();
mapTest();

View File

@ -29,7 +29,6 @@
#include "lib/framework/endian_hack.h"
#include "lib/framework/file.h"
#include "lib/framework/physfs_ext.h"
#include "lib/framework/tagfile.h"
#include "lib/ivis_opengl/tex.h"
#include "lib/netplay/netplay.h" // For syncDebug

View File

@ -27,10 +27,9 @@
#include <string.h>
// --------------------------------------------------------------------
#include "lib/framework/frame.h"
#include "lib/framework/wzapp.h"
#include "lib/framework/math_ext.h"
#include "lib/framework/strres.h"
#include "lib/framework/tagfile.h"
#include "lib/gamelib/gtime.h"
#include "console.h"
#include "scores.h"
@ -556,36 +555,29 @@ void fillUpStats( void )
infoBars[STAT_STR_BUILT].number = missionData.strBuilt;
}
static const char ScoreData_tag_definition[] = "tagdefinitions/savegame/score.def";
static const char ScoreData_file_identifier[] = "ScoreData";
// -----------------------------------------------------------------------------------
/* This will save out the score data */
bool writeScoreData(const char* fileName)
{
if (!tagOpenWrite(ScoreData_tag_definition, fileName))
WzConfig ini(fileName);
if (ini.status() != QSettings::NoError)
{
ASSERT(false, "writeScoreData: error while opening file (%s)", fileName);
debug(LOG_ERROR, "Could not open %s", fileName);
return false;
}
tagWriteString(0x01, ScoreData_file_identifier);
// Dump the scores for the current player
tagWrite(0x02, missionData.unitsBuilt);
tagWrite(0x03, missionData.unitsKilled);
tagWrite(0x04, missionData.unitsLost);
tagWrite(0x05, missionData.strBuilt);
tagWrite(0x06, missionData.strKilled);
tagWrite(0x07, missionData.strLost);
tagWrite(0x08, missionData.artefactsFound);
tagWrite(0x09, missionData.missionStarted);
tagWrite(0x0A, missionData.shotsOnTarget);
tagWrite(0x0B, missionData.shotsOffTarget);
tagWrite(0x0C, missionData.babasMowedDown);
// Close the file
tagClose();
ini.setValue("unitsBuilt", missionData.unitsBuilt);
ini.setValue("unitsKilled", missionData.unitsKilled);
ini.setValue("unitsLost", missionData.unitsLost);
ini.setValue("strBuilt", missionData.strBuilt);
ini.setValue("strKilled", missionData.strKilled);
ini.setValue("strLost", missionData.strLost);
ini.setValue("artefactsFound", missionData.artefactsFound);
ini.setValue("missionStarted", missionData.missionStarted);
ini.setValue("shotsOnTarget", missionData.shotsOnTarget);
ini.setValue("shotsOffTarget", missionData.shotsOffTarget);
ini.setValue("babasMowedDown", missionData.babasMowedDown);
// Everything is just fine!
return true;
@ -595,37 +587,25 @@ bool writeScoreData(const char* fileName)
/* This will read in the score data */
bool readScoreData(const char* fileName)
{
char strbuffer[25];
if (!tagOpenRead(ScoreData_tag_definition, fileName))
WzConfig ini(fileName);
if (ini.status() != QSettings::NoError)
{
debug(LOG_ERROR, "readFXData: error while opening file (%s)", fileName);
return false;
}
// Read & verify the format header identifier
tagReadString(0x01, sizeof(strbuffer), strbuffer);
if (strncmp(strbuffer, ScoreData_file_identifier, sizeof(strbuffer)) != 0)
{
debug(LOG_ERROR, "readScoreData: Weird file type found (in file %s)? Has header string: %s", fileName, strbuffer);
debug(LOG_ERROR, "Could not open %s", fileName);
return false;
}
// Retrieve the score data for the current player
missionData.unitsBuilt = tagRead(0x02);
missionData.unitsKilled = tagRead(0x03);
missionData.unitsLost = tagRead(0x04);
missionData.strBuilt = tagRead(0x05);
missionData.strKilled = tagRead(0x06);
missionData.strLost = tagRead(0x07);
missionData.artefactsFound = tagRead(0x08);
missionData.missionStarted = tagRead(0x09);
missionData.shotsOnTarget = tagRead(0x0A);
missionData.shotsOffTarget = tagRead(0x0B);
missionData.babasMowedDown = tagRead(0x0C);
// Close the file
tagClose();
missionData.unitsBuilt = ini.value("unitsBuilt").toInt();
missionData.unitsKilled = ini.value("unitsKilled").toInt();
missionData.unitsLost = ini.value("unitsLost").toInt();
missionData.strBuilt = ini.value("strBuilt").toInt();
missionData.strKilled = ini.value("strKilled").toInt();
missionData.strLost = ini.value("strLost").toInt();
missionData.artefactsFound = ini.value("artefactsFound").toInt();
missionData.missionStarted = ini.value("missionStarted").toInt();
missionData.shotsOnTarget = ini.value("shotsOnTarget").toInt();
missionData.shotsOffTarget = ini.value("shotsOffTarget").toInt();
missionData.babasMowedDown = ini.value("babasMowedDown").toInt();
/* Hopefully everything's just fine by now */
return true;