Author Topic: Java PMS Parser  (Read 3379 times)

0 Members and 1 Guest are viewing this topic.

Offline iDante

  • Veteran
  • *****
  • Posts: 1967
Java PMS Parser
« on: August 08, 2008, 05:30:59 am »
I wrote this a while ago, with the intent of making a program that takes an auto overview of maps. I got bored of that when I realized that java doesn't have a built in texture mapping class and that I would have to use OpenGL for it, in the form of JOGL. So, if anyone wants to do anything with maps in java, then this is for you.

Edit: Oh and if anyone wants me to make this into a jar (pack them all into one archive) then just ask.

Here is some info about it (included in dl):
Code: [Select]
How to use:
In your java program (that is in the same directory as this), make a new map instance by typing:

Map map = new Map(PathToMap);

For instance, if you want to print the polygon count of ctf_Ash, do this:

Map map = new Map("C:/Soldat/Maps/ctf_Ash.pms");
System.out.println(map.getPolyCount());


Class Definitions:

//////////////////////////////\\\\\\\\\\\\\\\\\\\\\\\\\\
Map
String getTitle()
String getTexture()
PMS_Color getTopColor()
PMS_Color getBottomColor()
int getJets()
int getGrenades()
int getMedKits()
int getWeather()
int getStepType()

int getPolyCount()
PMS_Polygon getPoly(int)
PMS_Polygon[] getAllPolys()

int getPropCount()
PMS_Prop getProp(int)
PMS_Prop[] getAllProps()

int getSceneryCount()
String getSceneryName(int)
String[] getAllSceneryNames()
int getDOSTime(int i)
int[] getAllDOSTime()
int getDOSDate(int i)
int[] getAllDOSDate()

int getColliderCount()
PMS_Collider getCollider(int)
PMS_Collider[] getAllColliders()

int getSpawnCount()
PMS_Spawn getSpawn(int i)
PMS_Spawn[] getAllSpawns()

int getWayPointCount()
PMS_Waypoint getWayPoint(int)
PMS_Waypoint[] getAllWayPoints()
//////////////////////////////\\\\\\\\\\\\\\\\\\\\\\\\\\
PMS_Color
Color getColor()
//////////////////////////////\\\\\\\\\\\\\\\\\\\\\\\\\\
PMS_Collider
boolean getActive()
float getX()
float getY()
float getRadius()
//////////////////////////////\\\\\\\\\\\\\\\\\\\\\\\\\\
PMS_Prop
boolean getActive()
int getPropStyle()
int getWidth()
int getHeight()
float getX()
float getY()
float getRotation()
float getScaleX()
float getScaleY()
int getAlpha()
PMS_Color getPMS_Color()
int getDrawBehind()
String getDrawBehindString()
//////////////////////////////\\\\\\\\\\\\\\\\\\\\\\\\\\
PMS_Vertex
float getX()
float getY()
float getZ()
float getRHW()
PMS_Color getPMS_Color();
float getTU()
float getTV()
//////////////////////////////\\\\\\\\\\\\\\\\\\\\\\\\\\
PMS_Vector
float getX()
float getY()
float getZ()
//////////////////////////////\\\\\\\\\\\\\\\\\\\\\\\\\\
PMS_Polygon
PMS_Vertex getVertex(int)
PMS_Vector getPerp(int)
int getPolyType()
String getPolyTypeString()
//////////////////////////////\\\\\\\\\\\\\\\\\\\\\\\\\\
PMS_Spawn
boolean getActive()
int getX()
int getY()
int getSpawnType()
String getSpawnTypeString()
//////////////////////////////\\\\\\\\\\\\\\\\\\\\\\\\\\
PMS_Waypoint
boolean getActive()
int getX()
int getY()
int getID()
boolean getLeft()
boolean getRight()
boolean getUp()
boolean getDown()
boolean getJet()
int getPath()
int getSpecialAction()
String getSpecialActionString()
int getC2()
int getC3()
int getNumConnections()
//////////////////////////////\\\\\\\\\\\\\\\\\\\\\\\\\\

« Last Edit: August 30, 2009, 02:20:31 pm by iDante »

Offline Railor

  • Major(1)
  • Posts: 16
Re: Java PMS Parser
« Reply #1 on: August 08, 2008, 06:17:20 am »
very nice! keep it up!

EDIT: hm.. if i try your example it says:
Code: [Select]
Exception in thread "main" java.lang.IllegalArgumentException: Color parameter outside of expected range: Alpha Green Blue
« Last Edit: August 08, 2008, 07:12:10 am by Railor »

Offline iDante

  • Veteran
  • *****
  • Posts: 1967
Re: Java PMS Parser
« Reply #2 on: August 08, 2008, 05:06:24 pm »
Fixed.

There is an issue with waypoints I need to get fixed, and until then they are disabled. For some reason when I view the waypoints in hex workshop (as well as in this program) they end abruptly some 50-100 waypoints before it is done. It can't be corrupt files because it happens with all of them.
If anyone drastically needs waypoints then PM me and I'll get them fixed up somehow.

I attached an image of the problem in hex workshop.
« Last Edit: August 08, 2008, 05:13:35 pm by iDante »

Offline chrisgbk

  • Inactive Staff
  • Veteran
  • *****
  • Posts: 1739
Re: Java PMS Parser
« Reply #3 on: August 11, 2008, 10:25:29 pm »
Fixed.

There is an issue with waypoints I need to get fixed, and until then they are disabled. For some reason when I view the waypoints in hex workshop (as well as in this program) they end abruptly some 50-100 waypoints before it is done. It can't be corrupt files because it happens with all of them.
If anyone drastically needs waypoints then PM me and I'll get them fixed up somehow.

I attached an image of the problem in hex workshop.

Your copy of the PMS structs file for hex workshop isn't parsing the file correctly, either due to an error in the structure file, or a problem with whatever version of hex workshop you are using.

In that particular file, the waypoint count, which is 216, should be at 0x00016314(90900) in the file, with actual waypoint data beginning at 0x00016318(90904) and ending at 0x0001C197(115096), with 52 bytes of garbage at the end of the file.

Ensure you load the structure at a locked offset of 0, not floating.
« Last Edit: August 11, 2008, 10:40:53 pm by chrisgbk »

Offline iDante

  • Veteran
  • *****
  • Posts: 1967
Re: Java PMS Parser
« Reply #4 on: August 12, 2008, 01:00:24 am »
I was doing it fine, the issue is that at the end of each spawnpoint there is actually 3 bytes of filler that was not in your struct thing. Thats why it got off :P
Am fixing it up right now, will be done and good in like 5 mins.
Edit: Updated
Edit2: That should be fixed on the wiki...
Edit3: Or maybe its because the last part of the spawnpoint is a long not a byte?
« Last Edit: August 12, 2008, 01:24:37 am by iDante »

Offline chrisgbk

  • Inactive Staff
  • Veteran
  • *****
  • Posts: 1739
Re: Java PMS Parser
« Reply #5 on: August 12, 2008, 08:59:20 pm »
Code: [Select]
typedef struct tagPMS_SPAWNPOINT {
BOOL active;
UBYTE filler[3];
LONG x;
LONG y;
PMS_SPAWNTEAM team;
} PMS_SPAWNPOINT;

Code: [Select]
#pragma enumsize(4) // 4 byte

typedef enum SPAWNTEAM {
stGENERAL = 0,
stALPHA,
stBRAVO,
stCHARLIE,
stDELTA,
stALPHA_FLAG,
stBRAVO_FLAG,
stGRENADES,
stMEDKITS,
stCLUSTERS,
stVEST,
stFLAMER,
stBERSERKER,
stPREDATOR,
stYELLOW_FLAG,
stRAMBO_BOW,
stSTAT_GUN
} PMS_SPAWNTEAM;

The last part is 4 bytes; that what the pragma is for; but the comment in some versions of hex workshop breaks it; remove the comment.
« Last Edit: August 12, 2008, 10:07:28 pm by chrisgbk »

Offline mxyzptlk

  • Veteran
  • *****
  • Posts: 1493
  • The Panda Ninja
Re: Java PMS Parser
« Reply #6 on: August 12, 2008, 09:11:50 pm »
There should be a sticky about the Wiki somewhere, or something about it in the news ticker.

"While preceding your entrance with a grenade is a good tactic in
Quake, it can lead to problems if attempted at work." -- C Hacking

Offline Doc

  • Soldier
  • **
  • Posts: 128
    • Soldat Files Directory
Re: Java PMS Parser
« Reply #7 on: August 13, 2008, 01:25:55 am »
oh noo, i though I already left a memo about those missing filler bytes when i made my php parser, i am sorry.