snprintf(buf, 63, "Textures/%s.png", args);
int id = Person::players[pnum]->numclothes;
- strcpy(Person::players[pnum]->clothes[id], buf);
+ strncpy(Person::players[pnum]->clothes[id], buf, 64);
Person::players[pnum]->clothestintr[id] = tintr;
Person::players[pnum]->clothestintg[id] = tintg;
Person::players[pnum]->clothestintb[id] = tintb;
void ch_map(const char *args)
{
- Loadlevel(args);
+ if (!LoadLevel(args)) {
+ // FIXME: Reduce code duplication with GameTick (should come from a Console class)
+ for (int k = 14; k >= 1; k--) {
+ consoletext[k] = consoletext[k - 1];
+ }
+ consoletext[0] = std::string("Could not load the requested level '") + args + "', aborting.";
+ consoleselected = 0;
+ }
whichlevel = -2;
campaign = 0;
}
void ch_save(const char *args)
{
- std::string map_path = Folders::getUserDataPath() + "/Maps/" + args;
+ std::string map_path = Folders::getUserDataPath() + "/Maps";
+ Folders::makeDirectory(map_path);
+ map_path = map_path + "/" + args;
int mapvers = 12;
FILE *tfile;
tfile = fopen( map_path.c_str(), "wb" );
+ if (tfile == NULL) {
+ perror((std::string("Couldn't open file ") + map_path + " for saving").c_str());
+ return;
+ }
fpackf(tfile, "Bi", mapvers);
fpackf(tfile, "Bi", maptype);
fpackf(tfile, "Bi", hostile);