Remove external files for missions, shop items, aliens and weapons.

The source code contains routines to initialise all these resources, but also
functions to load from and store to external files.  Support for external files
has now been removed; this removes a potential difference between compiling
with or without USEPAK, and makes it easier to change missions in the code.
This commit is contained in:
Guus Sliepen 2013-07-11 15:29:37 +02:00
parent bd4a449e10
commit 8810b090fa
35 changed files with 2 additions and 877 deletions

View File

@ -1,41 +0,0 @@
0 1 4 5 5 2 3 3 5 100 1 25 50 1 50 1
1 2 2 50 50 4 5 5 6 25 4 250 25 1 75 1
2 2 5 15 15 6 7 4 1 100 1 50 50 1 50 1
3 3 3 50 50 20 21 3 11 100 5 0 0 3 0 2
101 1 2 550 550 8 9 7 8 100 85 500 100 3 250 1
5 1 2 100 100 10 11 4 5 100 10 500 100 1 250 65
6 1 2 100 100 12 13 4 5 100 10 500 100 1 250 65
7 4 4 10 10 14 15 3 3 0 0 25 100 2 30 17
8 4 4 10 10 22 23 3 3 0 0 25 50 1 100 17
9 4 4 25 25 16 17 3 3 0 0 100 100 1 30 529
10 3 5 750 750 18 19 4 7 100 2 0 0 1 0 53249
11 1 3 15 15 8 9 14 14 7 1 50 75 1 100 1025
12 4 2 20 10 10 11 3 3 0 0 25 100 13 25 17
13 4 3 75 75 12 13 14 14 100 100 0 0 1 0 1042
14 1 3 50 50 24 25 16 16 100 0 0 0 1 0 1026
101 1 3 1000 1000 26 27 4 15 0 0 1000 100 1 255 5
16 1 1 250 250 28 29 4 15 0 0 1000 100 1 255 65
17 1 1 500 500 30 31 4 15 0 0 1000 100 1 255 131137
18 1 1 500 500 32 33 4 15 0 0 1000 100 1 255 131137
19 1 1 250 250 34 35 4 15 0 0 1000 100 1 255 65
20 3 8 5 5 36 37 3 9 100 0 0 10 5 1 1
21 3 6 1000 1000 10 11 15 6 100 5 550 100 3 255 270337
22 3 5 500 500 12 13 4 11 100 100 500 100 14 1 1
23 3 5 1000 1000 26 27 15 10 100 0 2000 100 1 255 6
101 1 5 1000 1000 28 28 15 11 0 0 2000 0 1 0 17
25 5 1 50 50 38 38 15 11 0 0 0 25 15 1 1
26 5 1 10 10 39 40 15 11 0 0 0 25 15 1 1
27 1 3 200 200 30 31 9 9 25 25 450 100 1 100 1
28 3 5 250 250 10 11 8 8 50 50 1000 75 5 2 1
29 3 2 100 100 32 33 6 7 50 2 0 0 5 0 2
30 3 4 500 500 12 13 6 7 50 2 1000 0 5 0 1
31 3 1 250 250 32 33 3 7 0 0 1000 100 1 25 17
32 3 4 800 800 12 13 3 7 100 0 1000 100 1 25 1
33 4 6 150 150 34 35 3 7 0 0 250 100 1 25 17
0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
35 3 5 250 250 0 1 4 6 100 5 500 100 1 250 1
36 3 4 750 750 41 42 15 6 100 5 500 100 1 250 1
37 3 4 250 250 43 44 6 6 5 0 500 100 1 250 5
38 3 4 250 250 45 46 6 6 5 0 500 100 1 250 5
0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0

View File

@ -1,13 +0,0 @@
Escape from WEAPCO Persuit
1 -1 -1 -2 0
0 -1 -1 -2 1
0 -1 -1 -2 1
0 -1 -1 -2 1
0 -1 -1 -2 1
0 -1 -1 -2 1
-1

View File

@ -1,13 +0,0 @@
Collect $500 to pay Mercenary for FIREFLY
3 3 500 -2 0
Destroy all remaining WEAPCO fighters
1 -1 -1 -2 0
0 -1 -1 -2 1
0 -1 -1 -2 1
0 -1 -1 -2 1
0 -1 -1 -2 1
300

View File

@ -1,13 +0,0 @@
Collect 6 Cargo Pods
3 6 6 -2 0
Do not destroy *ANY* Cargo Pods
4 6 0 -2 3
0 -1 -1 -2 1
Destroy all remaining WEAPCO fighters
1 -1 -1 -2 0
0 -1 -1 -2 1
0 -1 -1 -2 1
300

View File

@ -1,13 +0,0 @@
Destroy 5 WEAPCO Missile Boats
2 1 5 -2 0
0 -1 -1 -2 1
0 -1 -1 -2 1
Destroy all remaining WEAPCO fighters
1 -1 -1 -2 0
0 -1 -1 -2 1
0 -1 -1 -2 1
900

View File

@ -1,13 +0,0 @@
Destroy 9 WEAPCO Miners
2 9 9 -2 0
0 -1 -1 -2 1
0 -1 -1 -2 1
Destroy all remaining WEAPCO fighters
1 -1 -1 -2 0
0 -1 -1 -2 1
0 -1 -1 -2 1
900

View File

@ -1,13 +0,0 @@
Destroy WEAPCO Frigate
2 101 1 3 0
0 -1 -1 -2 1
0 -1 -1 -2 1
0 -1 -1 -2 1
0 -1 -1 -2 1
0 -1 -1 -2 1
2400

View File

@ -1,13 +0,0 @@
0 -1 -1 -2 1
0 -1 -1 -2 1
0 -1 -1 -2 1
0 -1 -1 -2 1
0 -1 -1 -2 1
0 -1 -1 -2 1
-1

View File

@ -1,13 +0,0 @@
Rescue Phoebe Lexx
2 8 1 -2 0
Do not allow Phoebe to be killed
5 102 0 -2 3
Destroy all WEAPCO forces
2 100 35 -2 0
0 -1 -1 -2 1
0 -1 -1 -2 1
0 -1 -1 -2 1
60

View File

@ -1,13 +0,0 @@
Assist medical supply craft
7 13 0 -2 0
Do not allow supply craft to be destroyed
5 13 0 -2 3
0 -1 -1 -2 1
Destroy all remaining WEAPCO fighters
1 -1 -1 -2 0
0 -1 -1 -2 1
0 -1 -1 -2 1
300

View File

@ -1,13 +0,0 @@
Disable five WEAPCO supply craft
6 8 5 -2 0
Destroy all remaining WEAPCO fighters
1 -1 -1 -2 0
Protect supply craft AND Sid Wilson
5 8 0 -2 3
0 -1 -1 -2 1
0 -1 -1 -2 1
0 -1 -1 -2 1
300

View File

@ -1,13 +0,0 @@
Locate doctor's escape pod
3 14 1 3 0
Do not destroy doctor's escape pod
4 14 1 -2 3
0 -1 -1 -2 1
Collect 10 pieces of Ore
3 15 10 3 0
0 -1 -1 -2 1
0 -1 -1 -2 1
60

View File

@ -1,13 +0,0 @@
Destroy WEAPCO ore mining craft
2 101 1 -2 0
Battle Kline
7 10 1 -2 4
0 -1 -1 -2 1
Save present slaves
4 13 -1 -2 3
0 -1 -1 -2 1
0 -1 -1 -2 1
-1

View File

@ -1,13 +0,0 @@
0 -1 -1 -2 1
0 -1 -1 -2 1
0 -1 -1 -2 1
0 -1 -1 -2 1
0 -1 -1 -2 1
0 -1 -1 -2 1
-1

View File

@ -1,13 +0,0 @@
Destroy Ursula's ship
2 22 0 -2 0
Capture Ursula's escape pod
3 14 1 -2 0
Do not kill Ursula
4 14 0 -2 3
Destroy all remaining WEAPCO fighters
1 -1 -1 -2 0
0 -1 -1 -2 1
0 -1 -1 -2 1
300

View File

@ -1,13 +0,0 @@
Assist attack on WEAPCO ore mining craft
2 101 1 -2 0
At least 1 rebel craft must survive
5 29 2 -2 3
Destroy all present WEAPCO forces
1 -1 -1 -2 0
0 -1 -1 -2 1
0 -1 -1 -2 1
0 -1 -1 -2 1
60

View File

@ -1,13 +0,0 @@
Collect 25 pieces of Ore
3 15 25 -2 0
0 -1 -1 -2 1
0 -1 -1 -2 1
Collect 25 pieces of Ore
3 15 25 -2 0
0 -1 -1 -2 1
0 -1 -1 -2 1
60

View File

@ -1,13 +0,0 @@
Collect $2000 to pay mercenary
3 3 2000 -2 0
Destroy all remaining WEAPCO fighters
1 -1 -1 -2 0
0 -1 -1 -2 1
0 -1 -1 -2 1
0 -1 -1 -2 1
0 -1 -1 -2 1
60

View File

@ -1,13 +0,0 @@
Destroy escorts
2 27 5 -2 0
Disable executive transport
7 101 1 -2 0
Destroy all remaining WEAPCO fighters
1 -1 -1 -2 0
0 -1 -1 -2 1
0 -1 -1 -2 1
0 -1 -1 -2 1
900

View File

@ -1,13 +0,0 @@
Destroy executive transport
2 101 1 -2 0
0 -1 -1 -2 1
0 -1 -1 -2 1
0 -1 -1 -2 1
0 -1 -1 -2 1
0 -1 -1 -2 1
60

View File

@ -1,13 +0,0 @@
Destroy planetary guardian
2 30 1 5 0
Destroy all remaining WEAPCO fighters
1 -1 -1 5 0
0 -1 -1 -2 1
0 -1 -1 -2 1
0 -1 -1 -2 1
0 -1 -1 -2 1
60

View File

@ -1,13 +0,0 @@
Destroy planetary guardian
2 32 1 5 0
Destroy all remaining WEAPCO fighters
1 -1 -1 5 0
0 -1 -1 -2 1
0 -1 -1 -2 1
0 -1 -1 -2 1
0 -1 -1 -2 1
60

View File

@ -1,13 +0,0 @@
Destroy all present WEAPCO forces
2 36 1 5 0
Destroy all remaining WEAPCO fighters
1 -1 -1 5 0
0 -1 -1 -2 1
0 -1 -1 -2 1
0 -1 -1 -2 1
0 -1 -1 -2 1
60

View File

@ -1,13 +0,0 @@
Destroy outer defence systems
2 28 6 -2 0
Destroy all remaining WEAPCO craft
1 -1 -1 -2 0
0 -1 -1 -2 1
0 -1 -1 -2 1
0 -1 -1 -2 1
0 -1 -1 -2 1
900

View File

@ -1,13 +0,0 @@
Investigate distress call
1 -1 -1 -2 3
Defeat Krass Tyler
2 35 4 -2 4
Destroy Krass' support group
1 -1 -1 -2 4
0 -1 -1 -2 1
0 -1 -1 -2 1
0 -1 -1 -2 1
60

View File

@ -1,13 +0,0 @@
Navigate asteroid belt
2 101 1 2 0
0 -1 -1 -2 1
0 -1 -1 -2 1
0 -1 -1 -2 1
0 -1 -1 -2 1
0 -1 -1 -2 1
60

View File

@ -1,13 +0,0 @@
Destroy WEAPCO frontline forces
2 100 100 -2 0
0 -1 -1 -2 1
0 -1 -1 -2 1
0 -1 -1 -2 1
0 -1 -1 -2 1
0 -1 -1 -2 1
60

View File

@ -1,13 +0,0 @@
Defeat Kline
1 -1 -1 -2 0
0 -1 -1 -2 1
0 -1 -1 -2 1
0 -1 -1 -2 1
0 -1 -1 -2 1
0 -1 -1 -2 1
-1

View File

@ -1,13 +0,0 @@
1 -1 -1 -2 0
0 -1 -1 -2 1
0 -1 -1 -2 1
0 -1 -1 -2 1
0 -1 -1 -2 1
0 -1 -1 -2 1
-1

View File

@ -1,52 +0,0 @@
Plasma channel splitter
Improves poweredup plasma output
1000 9 100 200
Plasma capacity condensor
Increases poweredup plasma damage
1000 10 150 200
Liquid nitrogen capsules
Increases plasma firing rate
1000 11 200 200
10 Plasma cells
Plasma ammunition
50 12 350 200
Rocket Ammo
High velocity dumb fire rocket
50 13 400 200
Additional Plasma Cannon
Adds an extra plasma cannon to the Firefly
2000 14 100 260
Plasma Power Booster
Increases power of plasma shots
2000 15 150 260
Plasma Cooling Booster
Permanently increases firing rate
2000 16 200 260
Plasma compressor
Increases plasma ammo capacity
250 17 450 200
Rocket Pod
Allows for an additional 5 rockets to be carried
250 18 500 200
Dual Rocket Launcher
Allows for two rockets to be fired at once
2000 19 350 260
Micro Rocket Launcher
Launches several less powerful rockets at once
2500 20 400 260
Laser Cannon
Laser Cannon
5000 21 450 260
Homing Missile Launcher
Fires homing missile (max 20 missiles)
7500 22 500 260
Charge Cannon
A charge up cannon
10000 23 550 260
Dual Homing Missile Launcher
Fires two homing missiles (max 10 missiles)
20000 24 600 260
Homing Micro Missile Launcher
Fires several small homing missiles (max 10)
25000 25 650 260

View File

@ -1,21 +0,0 @@
1 1 1 15 10 0 0 0
0 0 0 0 0 0 0 0
1 1 1 15 10 0 1 0
1 2 1 15 10 0 1 0
1 3 1 15 10 0 1 0
2 1 15 45 20 2 3 0
2 2 15 80 20 2 3 0
2 5 3 30 15 2 3 16
3 255 1 25 15 0 0 0
4 1 3 1 10 1 1 0
6 1 1 0 12 33 34 0
2 1 15 35 10 4 4 32
2 2 15 65 10 4 4 32
2 5 12 65 3 4 4 32
7 1 2 15 0 33 34 512
8 3 1 10 10 0 1 4
1 1 1 2 10 35 35 1536
2 5 20 60 0 4 4 2560
0 0 0 0 0 0 0 0
0 0 0 0 0 0 0 0

View File

@ -1257,105 +1257,6 @@ void setAlienShapes()
} }
} }
#if USEPACK
static void loadAliens()
{
int dataLocation = locateDataInPak("data/aliens.dat", 1);
int def, ai, speed, shield, max, image1, image2, weapon1, weapon2, chance1, chance2, score;
int collectChance, collectType, collectVal, flags;
FILE *fp;
fp = fopen(PACKLOCATION, "rb");
fseek(fp, dataLocation, SEEK_SET);
for (int i = 0 ; i < MAX_DEFALIENS ; i++)
{
fscanf(fp, "%d", &def);
fscanf(fp, "%d", &ai);
fscanf(fp, "%d", &speed);
fscanf(fp, "%d", &shield);
fscanf(fp, "%d", &max);
fscanf(fp, "%d", &image1);
fscanf(fp, "%d", &image2);
fscanf(fp, "%d", &weapon1);
fscanf(fp, "%d", &weapon2);
fscanf(fp, "%d", &chance1);
fscanf(fp, "%d", &chance2);
fscanf(fp, "%d", &score);
fscanf(fp, "%d", &collectChance);
fscanf(fp, "%d", &collectType);
fscanf(fp, "%d", &collectVal);
fscanf(fp, "%d", &flags);
defEnemy[i].classDef = def;
defEnemy[i].AIType = ai;
defEnemy[i].speed = speed;
defEnemy[i].shield = shield;
defEnemy[i].maxShield = max;
defEnemy[i].imageIndex[0] = image1;
defEnemy[i].imageIndex[1] = image2;
defEnemy[i].weaponType[0] = weapon1;
defEnemy[i].weaponType[1] = weapon2;
defEnemy[i].chance[0] = chance1;
defEnemy[i].chance[1] = chance2;
defEnemy[i].score = score;
defEnemy[i].collectChance = collectChance;
defEnemy[i].collectType = collectType;
defEnemy[i].collectValue = collectVal;
defEnemy[i].flags = flags;
}
fclose(fp);
}
void defineAliens(){loadAliens();}
#else
#if SAVEDATA
static void saveAliens()
{
FILE *fp;
fp = fopen("data/aliens.dat", "wb");
if (fp == NULL)
{
printf("Unable to write Alien Data File\n");
exit(1);
}
for (int i = 0 ; i < MAX_DEFALIENS ; i++)
{
fprintf(fp, "%d ", defEnemy[i].classDef);
fprintf(fp, "%d ", defEnemy[i].AIType);
fprintf(fp, "%d ", defEnemy[i].speed);
fprintf(fp, "%d ", defEnemy[i].shield);
fprintf(fp, "%d ", defEnemy[i].maxShield);
fprintf(fp, "%d ", defEnemy[i].imageIndex[0]);
fprintf(fp, "%d ", defEnemy[i].imageIndex[1]);
fprintf(fp, "%d ", defEnemy[i].weaponType[0]);
fprintf(fp, "%d ", defEnemy[i].weaponType[1]);
fprintf(fp, "%d ", defEnemy[i].chance[0]);
fprintf(fp, "%d ", defEnemy[i].chance[1]);
fprintf(fp, "%d ", defEnemy[i].score);
fprintf(fp, "%d ", defEnemy[i].collectChance);
fprintf(fp, "%d ", defEnemy[i].collectType);
fprintf(fp, "%d ", defEnemy[i].collectValue);
fprintf(fp, "%d\n", defEnemy[i].flags);
}
// Put an extra line for the PAK file "just in case"
fprintf(fp, "\n");
fclose(fp);
}
#endif
/*
Will be dumped into a data file at the end of the project
*/
void defineAliens() void defineAliens()
{ {
// Dual Plasma Fighter. // Dual Plasma Fighter.
@ -2034,10 +1935,4 @@ void defineAliens()
defEnemy[CD_URANUSBOSSWING2].collectType = P_ANYTHING; defEnemy[CD_URANUSBOSSWING2].collectType = P_ANYTHING;
defEnemy[CD_URANUSBOSSWING2].collectValue = 250; defEnemy[CD_URANUSBOSSWING2].collectValue = 250;
defEnemy[CD_URANUSBOSSWING2].flags = FL_WEAPCO | FL_IMMORTAL; defEnemy[CD_URANUSBOSSWING2].flags = FL_WEAPCO | FL_IMMORTAL;
#if SAVEDATA
saveAliens();
#endif
} }
#endif

View File

@ -905,129 +905,8 @@ void missionFinishedScreen()
Mix_HaltMusic(); Mix_HaltMusic();
} }
#if USEPACK
static void loadMissions()
{
clearAllMissions();
FILE *fp;
int dataLocation;
char filename[65];
char objective[255];
int type, target, value, time, complete, add;
for (int i = 0 ; i < MAX_MISSIONS ; i++)
{
sprintf(filename, "data/mission%.2d.dat", i);
#if USEPACK
dataLocation = locateDataInPak(filename, 1);
fp = fopen(PACKLOCATION, "rb");
fseek(fp, dataLocation, SEEK_SET);
#else
fp = fopen(filename, "rb");
#endif
for (int j = 0 ; j < 3 ; j++)
{
fscanf(fp, "%[^\n]%*c", objective);
fscanf(fp, "%d", &type);
fscanf(fp, "%d", &target);
fscanf(fp, "%d", &value);
fscanf(fp, "%d", &time);
fscanf(fp, "%d%*c", &complete);
strcpy(missions[i].primaryObjective[j], objective);
missions[i].primaryType[j] = type;
missions[i].target1[j] = target;
missions[i].targetValue1[j] = value;
missions[i].timeLimit1[j] = time;
missions[i].completed1[j] = complete;
}
for (int j = 0 ; j < 3 ; j++)
{
fscanf(fp, "%[^\n]%*c", objective);
fscanf(fp, "%d", &type);
fscanf(fp, "%d", &target);
fscanf(fp, "%d", &value);
fscanf(fp, "%d", &time);
fscanf(fp, "%d%*c", &complete);
strcpy(missions[i].secondaryObjective[j], objective);
missions[i].secondaryType[j] = type;
missions[i].target2[j] = target;
missions[i].targetValue2[j] = value;
missions[i].timeLimit2[j] = time;
missions[i].completed2[j] = complete;
}
fscanf(fp, "%d", &add);
missions[i].addAliens = add;
fclose(fp);
}
}
void initMissions(){loadMissions();}
#else
#if SAVEDATA
static void saveMissions()
{
FILE *fp;
char filename[65];
for (int i = 0 ; i < MAX_MISSIONS ; i++)
{
sprintf(filename, "data/mission%.2d.dat", i);
//WRITE MISSION DATA
fp = fopen(filename, "wb");
if (fp == NULL)
{
printf("Unable to write Mission Data File (%s)\n", filename);
exit(1);
}
for (int j = 0 ; j < 3 ; j++)
{
fprintf(fp, "%s\n", missions[i].primaryObjective[j]);
fprintf(fp, "%d ", missions[i].primaryType[j]);
fprintf(fp, "%d ", missions[i].target1[j]);
fprintf(fp, "%d ", missions[i].targetValue1[j]);
fprintf(fp, "%d ", missions[i].timeLimit1[j]);
fprintf(fp, "%d\n", missions[i].completed1[j]);
}
for (int j = 0 ; j < 3 ; j++)
{
fprintf(fp, "%s\n", missions[i].secondaryObjective[j]);
fprintf(fp, "%d ", missions[i].secondaryType[j]);
fprintf(fp, "%d ", missions[i].target2[j]);
fprintf(fp, "%d ", missions[i].targetValue2[j]);
fprintf(fp, "%d ", missions[i].timeLimit2[j]);
fprintf(fp, "%d\n", missions[i].completed2[j]);
}
fprintf(fp, "%d ", missions[i].addAliens);
// Put an extra line for the PAK file "just in case"
fprintf(fp, "\n");
fclose(fp);
}
}
#endif
/* /*
This is where all the missions are defined. This will be placed This is where all the missions are defined.
into a data file when the game is finished.
*/ */
void initMissions() void initMissions()
{ {
@ -1436,9 +1315,4 @@ void initMissions()
strcpy(missions[MAX_MISSIONS - 1].primaryObjective[0], ""); strcpy(missions[MAX_MISSIONS - 1].primaryObjective[0], "");
missions[MAX_MISSIONS - 1].primaryType[0] = M_DESTROY_ALL_TARGETS; missions[MAX_MISSIONS - 1].primaryType[0] = M_DESTROY_ALL_TARGETS;
missions[MAX_MISSIONS - 1].completed1[0] = OB_INCOMPLETE; missions[MAX_MISSIONS - 1].completed1[0] = OB_INCOMPLETE;
#if SAVEDATA
saveMissions();
#endif
} }
#endif

View File

@ -260,87 +260,6 @@ static void drawShop()
} }
} }
#if USEPACK
static void loadShop()
{
char name[255], description[255];
int price, image, x, y;
FILE *fp;
#if USEPACK
int dataLocation = locateDataInPak("data/shop.dat", 1);
fp = fopen(PACKLOCATION, "rb");
fseek(fp, dataLocation, SEEK_SET);
#else
fp = fopen("data/shop.dat", "rb");
#endif
for (int i = 0 ; i < MAX_SHOPITEMS ; i++)
{
fscanf(fp, "%[^\n]%*c", name);
fscanf(fp, "%[^\n]%*c", description);
fscanf(fp, "%d", &price);
fscanf(fp, "%d", &image);
fscanf(fp, "%d", &x);
fscanf(fp, "%d%*c", &y);
strcpy(shopItems[i].name, name);
strcpy(shopItems[i].description, description);
shopItems[i].price = price;
shopItems[i].image = image;
shopItems[i].x = x;
shopItems[i].y = y;
}
fclose(fp);
shopSelectedItem = -1;
player.image[0] = shape[0];
player.x = 380;
player.y = 95;
drawShop();
}
void initShop(){loadShop();}
#else
#if SAVEDATA
static void saveShop()
{
FILE *fp;
fp = fopen("data/shop.dat", "wb");
if (fp == NULL)
{
printf("Unable to write Shop Data File\n");
exit(1);
}
for (int i = 0 ; i < MAX_SHOPITEMS ; i++)
{
fprintf(fp, "%s\n", shopItems[i].name);
fprintf(fp, "%s\n", shopItems[i].description);
fprintf(fp, "%d ", shopItems[i].price);
fprintf(fp, "%d ", shopItems[i].image);
fprintf(fp, "%d ", shopItems[i].x);
fprintf(fp, "%d\n", shopItems[i].y);
}
// Put an extra line for the PAK file "just in case"
fprintf(fp, "\n");
fclose(fp);
}
#endif
/*
Throw into a data file in final build
*/
void initShop() void initShop()
{ {
/* ----------- Temporary Items ----------- */ /* ----------- Temporary Items ----------- */
@ -472,15 +391,9 @@ void initShop()
player.x = 380; player.x = 380;
player.y = 95; player.y = 95;
#if SAVEDATA
saveShop();
#endif
drawShop(); drawShop();
} }
#endif
static void buy(int i) static void buy(int i)
{ {
if ((currentGame.cash < shopItems[i].price) && (!engine.cheatCash)) if ((currentGame.cash < shopItems[i].price) && (!engine.cheatCash))
@ -789,4 +702,3 @@ void showShop()
} }
} }
} }

View File

@ -31,80 +31,8 @@ void setWeaponShapes()
} }
} }
#if USEPACK
static void loadWeapons()
{
int dataLocation = locateDataInPak("data/weapons.dat", 1);
int id, ammo, damage, reload, speed, image1, image2, flags;
FILE *fp;
fp = fopen(PACKLOCATION, "rb");
fseek(fp, dataLocation, SEEK_SET);
for (int i = 0 ; i < MAX_WEAPONS ; i++)
{
fscanf(fp, "%d", &id);
fscanf(fp, "%d", &ammo);
fscanf(fp, "%d", &damage);
fscanf(fp, "%d", &reload);
fscanf(fp, "%d", &speed);
fscanf(fp, "%d", &image1);
fscanf(fp, "%d", &image2);
fscanf(fp, "%d", &flags);
weapon[i].id = id;
weapon[i].ammo[0] = ammo;
weapon[i].damage = damage;
weapon[i].reload[0] = reload;
weapon[i].speed = speed;
weapon[i].imageIndex[0] = image1;
weapon[i].imageIndex[1] = image2;
weapon[i].flags = flags;
}
fclose(fp);
}
void initWeapons() {loadWeapons();}
#else
#if SAVEDATA
static void saveWeapons()
{
FILE *fp;
fp = fopen("data/weapons.dat", "wb");
if (fp == NULL)
{
printf("Unable to write Weapon Data File\n");
exit(1);
}
for (int i = 0 ; i < MAX_WEAPONS ; i++)
{
fprintf(fp, "%d ", weapon[i].id);
fprintf(fp, "%d ", weapon[i].ammo[0]);
fprintf(fp, "%d ", weapon[i].damage);
fprintf(fp, "%d ", weapon[i].reload[0]);
fprintf(fp, "%d ", weapon[i].speed);
fprintf(fp, "%d ", weapon[i].imageIndex[0]);
fprintf(fp, "%d ", weapon[i].imageIndex[1]);
fprintf(fp, "%d\n", weapon[i].flags);
}
// Put an extra line for the PAK file "just in case"
fprintf(fp, "\n");
fclose(fp);
}
#endif
/* /*
A list of predefined weaponary. Will most probably A list of predefined weaponary.
be placed into a data file in the final build.
*/ */
void initWeapons() void initWeapons()
{ {
@ -255,10 +183,4 @@ void initWeapons()
weapon[W_DIRSHOCKMISSILE].flags = WF_AIMED | WF_TIMEDEXPLOSION; weapon[W_DIRSHOCKMISSILE].flags = WF_AIMED | WF_TIMEDEXPLOSION;
weapon[W_DIRSHOCKMISSILE].imageIndex[0] = 4; weapon[W_DIRSHOCKMISSILE].imageIndex[0] = 4;
weapon[W_DIRSHOCKMISSILE].imageIndex[1] = 4; weapon[W_DIRSHOCKMISSILE].imageIndex[1] = 4;
#if SAVEDATA
saveWeapons();
#endif
} }
#endif