mirror of
https://github.com/nzp-team/quakespasm.git
synced 2025-02-18 09:31:13 +00:00
Merge pull request #38 from tyleryoung88/main
This commit is contained in:
commit
774072a853
1 changed files with 64 additions and 54 deletions
118
source/menu.c
118
source/menu.c
|
@ -1699,6 +1699,7 @@ void Map_Finder(void)
|
||||||
DIR* dir;
|
DIR* dir;
|
||||||
struct dirent* ent;
|
struct dirent* ent;
|
||||||
char map_dir[MAX_OSPATH];
|
char map_dir[MAX_OSPATH];
|
||||||
|
qboolean breakaway;
|
||||||
|
|
||||||
for (int i = 0; i < 50; i++) {
|
for (int i = 0; i < 50; i++) {
|
||||||
custom_maps[i].occupied = false;
|
custom_maps[i].occupied = false;
|
||||||
|
@ -1716,87 +1717,96 @@ void Map_Finder(void)
|
||||||
{
|
{
|
||||||
if(!strcmp(COM_FileGetExtension(ent->d_name),"bsp") || !strcmp(COM_FileGetExtension(ent->d_name),"BSP"))
|
if(!strcmp(COM_FileGetExtension(ent->d_name),"bsp") || !strcmp(COM_FileGetExtension(ent->d_name),"BSP"))
|
||||||
{
|
{
|
||||||
qboolean breakaway = false;
|
breakaway = false;
|
||||||
char ntype[32];
|
char ntype[32];
|
||||||
COM_StripExtension(ent->d_name, ntype, sizeof(ntype));
|
COM_StripExtension(ent->d_name, ntype, sizeof(ntype));
|
||||||
|
|
||||||
for (int j = 0; j < BASE_MAP_COUNT; j++)
|
for (int j = 0; j < BASE_MAP_COUNT; j++)
|
||||||
{
|
{
|
||||||
if (breakaway == true)
|
if (breakaway == true)
|
||||||
return;
|
break;
|
||||||
|
|
||||||
if(!strcmp(ntype, base_maps[j]))
|
if(!strcmp(ntype, base_maps[j]))
|
||||||
|
{
|
||||||
|
//Con_Printf("ntype: %s\n base_map: %s\n", ntype, base_maps[j]);
|
||||||
breakaway = true;
|
breakaway = true;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (breakaway == true)
|
if (breakaway == true)
|
||||||
|
{
|
||||||
|
//Con_Printf("Breaking away at ntype: %s\n", ntype);
|
||||||
continue;
|
continue;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
//Con_Printf("Success at ntype: %s\n", ntype);
|
||||||
|
custom_maps[user_maps_num].occupied = true;
|
||||||
|
custom_maps[user_maps_num].map_name = malloc(sizeof(char)*32);
|
||||||
|
sprintf(custom_maps[user_maps_num].map_name, "%s", ntype);
|
||||||
|
|
||||||
custom_maps[user_maps_num].occupied = true;
|
char* setting_path;
|
||||||
custom_maps[user_maps_num].map_name = malloc(sizeof(char)*32);
|
FILE* setting_file;
|
||||||
sprintf(custom_maps[user_maps_num].map_name, "%s", ntype);
|
|
||||||
|
|
||||||
char* setting_path;
|
setting_path = malloc(sizeof(char)*64);
|
||||||
FILE* setting_file;
|
custom_maps[user_maps_num].map_thumbnail_path = malloc(sizeof(char)*64);
|
||||||
|
|
||||||
setting_path = malloc(sizeof(char)*64);
|
strcpy(setting_path, map_dir);
|
||||||
custom_maps[user_maps_num].map_thumbnail_path = malloc(sizeof(char)*64);
|
strcat(setting_path, "/");
|
||||||
|
|
||||||
strcpy(setting_path, map_dir);
|
strcpy(custom_maps[user_maps_num].map_thumbnail_path, "gfx/menu/custom/");
|
||||||
strcat(setting_path, "/");
|
strcat(setting_path, custom_maps[user_maps_num].map_name);
|
||||||
|
strcat(custom_maps[user_maps_num].map_thumbnail_path, custom_maps[user_maps_num].map_name);
|
||||||
|
strcat(custom_maps[user_maps_num].map_thumbnail_path, ".tga");
|
||||||
|
strcat(setting_path, ".txt");
|
||||||
|
|
||||||
strcpy(custom_maps[user_maps_num].map_thumbnail_path, "gfx/menu/custom/");
|
setting_file = fopen(setting_path, "r");
|
||||||
strcat(setting_path, custom_maps[user_maps_num].map_name);
|
|
||||||
strcat(custom_maps[user_maps_num].map_thumbnail_path, custom_maps[user_maps_num].map_name);
|
|
||||||
strcat(custom_maps[user_maps_num].map_thumbnail_path, ".tga");
|
|
||||||
strcat(setting_path, ".txt");
|
|
||||||
|
|
||||||
setting_file = fopen(setting_path, "r");
|
if (setting_file != NULL) {
|
||||||
|
int state;
|
||||||
|
state = 0;
|
||||||
|
int value;
|
||||||
|
|
||||||
if (setting_file != NULL) {
|
custom_maps[user_maps_num].map_name_pretty = malloc(sizeof(char)*32);
|
||||||
int state;
|
custom_maps[user_maps_num].map_desc_1 = malloc(sizeof(char)*40);
|
||||||
state = 0;
|
custom_maps[user_maps_num].map_desc_2 = malloc(sizeof(char)*40);
|
||||||
int value;
|
custom_maps[user_maps_num].map_desc_3 = malloc(sizeof(char)*40);
|
||||||
|
custom_maps[user_maps_num].map_desc_4 = malloc(sizeof(char)*40);
|
||||||
|
custom_maps[user_maps_num].map_desc_5 = malloc(sizeof(char)*40);
|
||||||
|
custom_maps[user_maps_num].map_desc_6 = malloc(sizeof(char)*40);
|
||||||
|
custom_maps[user_maps_num].map_desc_7 = malloc(sizeof(char)*40);
|
||||||
|
custom_maps[user_maps_num].map_desc_8 = malloc(sizeof(char)*40);
|
||||||
|
custom_maps[user_maps_num].map_author = malloc(sizeof(char)*40);
|
||||||
|
|
||||||
custom_maps[user_maps_num].map_name_pretty = malloc(sizeof(char)*32);
|
char buffer[64];
|
||||||
custom_maps[user_maps_num].map_desc_1 = malloc(sizeof(char)*40);
|
int bufferlen = sizeof(buffer);
|
||||||
custom_maps[user_maps_num].map_desc_2 = malloc(sizeof(char)*40);
|
|
||||||
custom_maps[user_maps_num].map_desc_3 = malloc(sizeof(char)*40);
|
|
||||||
custom_maps[user_maps_num].map_desc_4 = malloc(sizeof(char)*40);
|
|
||||||
custom_maps[user_maps_num].map_desc_5 = malloc(sizeof(char)*40);
|
|
||||||
custom_maps[user_maps_num].map_desc_6 = malloc(sizeof(char)*40);
|
|
||||||
custom_maps[user_maps_num].map_desc_7 = malloc(sizeof(char)*40);
|
|
||||||
custom_maps[user_maps_num].map_desc_8 = malloc(sizeof(char)*40);
|
|
||||||
custom_maps[user_maps_num].map_author = malloc(sizeof(char)*40);
|
|
||||||
|
|
||||||
char buffer[64];
|
while(fgets(buffer, bufferlen, setting_file)) {
|
||||||
int bufferlen = sizeof(buffer);
|
// strip newlines
|
||||||
|
buffer[strcspn(buffer, "\r")] = 0;
|
||||||
|
buffer[strcspn(buffer, "\n")] = 0;
|
||||||
|
|
||||||
while(fgets(buffer, bufferlen, setting_file)) {
|
switch(state) {
|
||||||
// strip newlines
|
case 0: strcpy(custom_maps[user_maps_num].map_name_pretty, buffer); break;
|
||||||
buffer[strcspn(buffer, "\r")] = 0;
|
case 1: strcpy(custom_maps[user_maps_num].map_desc_1, buffer); break;
|
||||||
buffer[strcspn(buffer, "\n")] = 0;
|
case 2: strcpy(custom_maps[user_maps_num].map_desc_2, buffer); break;
|
||||||
|
case 3: strcpy(custom_maps[user_maps_num].map_desc_3, buffer); break;
|
||||||
switch(state) {
|
case 4: strcpy(custom_maps[user_maps_num].map_desc_4, buffer); break;
|
||||||
case 0: strcpy(custom_maps[user_maps_num].map_name_pretty, buffer); break;
|
case 5: strcpy(custom_maps[user_maps_num].map_desc_5, buffer); break;
|
||||||
case 1: strcpy(custom_maps[user_maps_num].map_desc_1, buffer); break;
|
case 6: strcpy(custom_maps[user_maps_num].map_desc_6, buffer); break;
|
||||||
case 2: strcpy(custom_maps[user_maps_num].map_desc_2, buffer); break;
|
case 7: strcpy(custom_maps[user_maps_num].map_desc_7, buffer); break;
|
||||||
case 3: strcpy(custom_maps[user_maps_num].map_desc_3, buffer); break;
|
case 8: strcpy(custom_maps[user_maps_num].map_desc_8, buffer); break;
|
||||||
case 4: strcpy(custom_maps[user_maps_num].map_desc_4, buffer); break;
|
case 9: strcpy(custom_maps[user_maps_num].map_author, buffer); break;
|
||||||
case 5: strcpy(custom_maps[user_maps_num].map_desc_5, buffer); break;
|
case 10: value = 0; sscanf(buffer, "%d", &value); custom_maps[user_maps_num].map_use_thumbnail = value; break;
|
||||||
case 6: strcpy(custom_maps[user_maps_num].map_desc_6, buffer); break;
|
case 11: value = 0; sscanf(buffer, "%d", &value); custom_maps[user_maps_num].map_allow_game_settings = value; break;
|
||||||
case 7: strcpy(custom_maps[user_maps_num].map_desc_7, buffer); break;
|
default: break;
|
||||||
case 8: strcpy(custom_maps[user_maps_num].map_desc_8, buffer); break;
|
}
|
||||||
case 9: strcpy(custom_maps[user_maps_num].map_author, buffer); break;
|
state++;
|
||||||
case 10: value = 0; sscanf(buffer, "%d", &value); custom_maps[user_maps_num].map_use_thumbnail = value; break;
|
|
||||||
case 11: value = 0; sscanf(buffer, "%d", &value); custom_maps[user_maps_num].map_allow_game_settings = value; break;
|
|
||||||
default: break;
|
|
||||||
}
|
}
|
||||||
state++;
|
|
||||||
}
|
|
||||||
fclose(setting_file);
|
fclose(setting_file);
|
||||||
}
|
}
|
||||||
user_maps_num = user_maps_num + 1;
|
user_maps_num = user_maps_num + 1;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
closedir(dir);
|
closedir(dir);
|
||||||
|
|
Loading…
Reference in a new issue