Skip to content

Commit

Permalink
mapconv: Add command line option -cam to generate map data appropriat…
Browse files Browse the repository at this point in the history
…e for campaign.
  • Loading branch information
perim committed Oct 29, 2011
1 parent cdd76ef commit 3e53f79
Showing 1 changed file with 20 additions and 5 deletions.
25 changes: 20 additions & 5 deletions tools/map/mapconv.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -33,16 +33,22 @@ int main(int argc, char **argv)
char filename[PATH_MAX], *p_filename, *base, *mapname;
GAMEMAP *map;
FILE *fp;
int i;
int i, argn = 1;
bool campaign = false;

if (argc != 2)
if (argc < 2)
{
printf("Usage: %s <map>\n", argv[0]);
return -1;
}
if (argc == 3 && strcmp(argv[1], "-cam") == 0)
{
campaign = true;
argn++;
}

physfs_init(argv[0]);
strcpy(filename, physfs_addmappath(argv[1]));
strcpy(filename, physfs_addmappath(argv[argn]));

map = mapLoad(filename);
if (!map)
Expand Down Expand Up @@ -224,6 +230,7 @@ int main(int argc, char **argv)
{
strcpy(filename, base);
strcat(filename, "/struct.ini");
printf("writing %s\n", filename);
fp = fopen(filename, "w");
if (!fp) printf("%s: %s\n", filename, strerror(errno));
for (i = 0; i < map->numStructures; i++)
Expand All @@ -243,7 +250,11 @@ int main(int argc, char **argv)
MADD("position = %u, %u, %u", psObj->x, psObj->y, psObj->z);
MADD("rotation = %u, 0, 0", DEG(psObj->direction));
MADD("name = %s", psObj->name);
if (psObj->player < map->numPlayers)
if (campaign)
{
MADD("player = %u", psObj->player);
}
else if (psObj->player < map->numPlayers)
{
MADD("startpos = %u", psObj->player);
}
Expand Down Expand Up @@ -311,7 +322,11 @@ int main(int argc, char **argv)
MADD("id = %u", psObj->id);
MADD("position = %u, %u, %u", psObj->x, psObj->y, psObj->z);
MADD("rotation = %u, 0, 0", DEG(psObj->direction));
if (psObj->player < map->numPlayers)
if (campaign)
{
MADD("player = %u", psObj->player);
}
else if (psObj->player < map->numPlayers)
{
MADD("startpos = %u", psObj->player);
}
Expand Down

0 comments on commit 3e53f79

Please sign in to comment.