Define Powerup_names only if EDITOR
This commit is contained in:
parent
7d07c24a5a
commit
fee76e6ced
|
@ -96,6 +96,10 @@ enum powerup_type_t : uint8_t
|
||||||
};
|
};
|
||||||
|
|
||||||
#ifdef dsx
|
#ifdef dsx
|
||||||
|
namespace dcx {
|
||||||
|
constexpr unsigned POWERUP_NAME_LENGTH = 16;
|
||||||
|
}
|
||||||
|
|
||||||
namespace dsx {
|
namespace dsx {
|
||||||
#if defined(DXX_BUILD_DESCENT_I)
|
#if defined(DXX_BUILD_DESCENT_I)
|
||||||
#define VULCAN_AMMO_MAX (392u*2)
|
#define VULCAN_AMMO_MAX (392u*2)
|
||||||
|
@ -109,7 +113,10 @@ constexpr unsigned MAX_POWERUP_TYPES = 50;
|
||||||
#define VULCAN_WEAPON_AMMO_AMOUNT 196
|
#define VULCAN_WEAPON_AMMO_AMOUNT 196
|
||||||
#define VULCAN_AMMO_AMOUNT (49*2)
|
#define VULCAN_AMMO_AMOUNT (49*2)
|
||||||
|
|
||||||
#define POWERUP_NAME_LENGTH 16 // Length of a robot or powerup name.
|
#ifdef EDITOR
|
||||||
|
using powerup_names_array = array<array<char, POWERUP_NAME_LENGTH>, MAX_POWERUP_TYPES>;
|
||||||
|
extern powerup_names_array Powerup_names;
|
||||||
|
#endif
|
||||||
|
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
@ -124,7 +131,6 @@ struct powerup_type_info : public prohibit_void_ptr<powerup_type_info>
|
||||||
|
|
||||||
namespace dsx {
|
namespace dsx {
|
||||||
extern array<powerup_type_info, MAX_POWERUP_TYPES> Powerup_info;
|
extern array<powerup_type_info, MAX_POWERUP_TYPES> Powerup_info;
|
||||||
extern array<char[POWERUP_NAME_LENGTH], MAX_POWERUP_TYPES> Powerup_names;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void powerup_type_info_read(PHYSFS_File *fp, powerup_type_info &pti);
|
void powerup_type_info_read(PHYSFS_File *fp, powerup_type_info &pti);
|
||||||
|
|
|
@ -98,7 +98,9 @@ static short N_ObjBitmaps=0;
|
||||||
static short N_ObjBitmapPtrs=0;
|
static short N_ObjBitmapPtrs=0;
|
||||||
static int Num_robot_ais = 0;
|
static int Num_robot_ais = 0;
|
||||||
namespace dsx {
|
namespace dsx {
|
||||||
array<char[POWERUP_NAME_LENGTH], MAX_POWERUP_TYPES> Powerup_names;
|
#ifdef EDITOR
|
||||||
|
powerup_names_array Powerup_names;
|
||||||
|
#endif
|
||||||
array<char[ROBOT_NAME_LENGTH], MAX_ROBOT_TYPES> Robot_names;
|
array<char[ROBOT_NAME_LENGTH], MAX_ROBOT_TYPES> Robot_names;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1673,7 +1675,9 @@ void bm_read_powerup(char *&arg, int unused_flag)
|
||||||
Powerup_info[n].vclip_num = vclip_none;
|
Powerup_info[n].vclip_num = vclip_none;
|
||||||
Powerup_info[n].hit_sound = sound_none;
|
Powerup_info[n].hit_sound = sound_none;
|
||||||
Powerup_info[n].size = DEFAULT_POWERUP_SIZE;
|
Powerup_info[n].size = DEFAULT_POWERUP_SIZE;
|
||||||
|
#ifdef EDITOR
|
||||||
Powerup_names[n][0] = 0;
|
Powerup_names[n][0] = 0;
|
||||||
|
#endif
|
||||||
|
|
||||||
// Process arguments
|
// Process arguments
|
||||||
arg = strtok( NULL, space_tab );
|
arg = strtok( NULL, space_tab );
|
||||||
|
@ -1691,9 +1695,13 @@ void bm_read_powerup(char *&arg, int unused_flag)
|
||||||
} else if (!d_stricmp( arg, "hit_sound" )) {
|
} else if (!d_stricmp( arg, "hit_sound" )) {
|
||||||
Powerup_info[n].hit_sound = atoi(equal_ptr);
|
Powerup_info[n].hit_sound = atoi(equal_ptr);
|
||||||
} else if (!d_stricmp( arg, "name" )) {
|
} else if (!d_stricmp( arg, "name" )) {
|
||||||
Assert(strlen(equal_ptr) < POWERUP_NAME_LENGTH); // Oops, name too long.
|
#ifdef EDITOR
|
||||||
strcpy(Powerup_names[n], &equal_ptr[1]);
|
auto &name = Powerup_names[n];
|
||||||
Powerup_names[n][strlen(Powerup_names[n])-1] = 0;
|
const auto len = strlen(equal_ptr);
|
||||||
|
assert(len < name.size()); // Oops, name too long.
|
||||||
|
memcpy(name.data(), &equal_ptr[1], len - 2);
|
||||||
|
name[len - 2] = 0;
|
||||||
|
#endif
|
||||||
} else if (!d_stricmp( arg, "size" )) {
|
} else if (!d_stricmp( arg, "size" )) {
|
||||||
Powerup_info[n].size = fl2f(atof(equal_ptr));
|
Powerup_info[n].size = fl2f(atof(equal_ptr));
|
||||||
}
|
}
|
||||||
|
|
|
@ -91,7 +91,9 @@ using std::min;
|
||||||
static short N_ObjBitmapPtrs=0;
|
static short N_ObjBitmapPtrs=0;
|
||||||
static int Num_robot_ais = 0;
|
static int Num_robot_ais = 0;
|
||||||
namespace dsx {
|
namespace dsx {
|
||||||
array<char[POWERUP_NAME_LENGTH], MAX_POWERUP_TYPES> Powerup_names;
|
#ifdef EDITOR
|
||||||
|
powerup_names_array Powerup_names;
|
||||||
|
#endif
|
||||||
array<char[ROBOT_NAME_LENGTH], MAX_ROBOT_TYPES> Robot_names;
|
array<char[ROBOT_NAME_LENGTH], MAX_ROBOT_TYPES> Robot_names;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -2008,7 +2010,9 @@ void bm_read_powerup(int unused_flag)
|
||||||
Powerup_info[n].vclip_num = vclip_none;
|
Powerup_info[n].vclip_num = vclip_none;
|
||||||
Powerup_info[n].hit_sound = sound_none;
|
Powerup_info[n].hit_sound = sound_none;
|
||||||
Powerup_info[n].size = DEFAULT_POWERUP_SIZE;
|
Powerup_info[n].size = DEFAULT_POWERUP_SIZE;
|
||||||
|
#ifdef EDITOR
|
||||||
Powerup_names[n][0] = 0;
|
Powerup_names[n][0] = 0;
|
||||||
|
#endif
|
||||||
|
|
||||||
// Process arguments
|
// Process arguments
|
||||||
arg = strtok( NULL, space_tab );
|
arg = strtok( NULL, space_tab );
|
||||||
|
@ -2026,9 +2030,13 @@ void bm_read_powerup(int unused_flag)
|
||||||
} else if (!d_stricmp( arg, "hit_sound" )) {
|
} else if (!d_stricmp( arg, "hit_sound" )) {
|
||||||
Powerup_info[n].hit_sound = atoi(equal_ptr);
|
Powerup_info[n].hit_sound = atoi(equal_ptr);
|
||||||
} else if (!d_stricmp( arg, "name" )) {
|
} else if (!d_stricmp( arg, "name" )) {
|
||||||
Assert(strlen(equal_ptr) < POWERUP_NAME_LENGTH); // Oops, name too long.
|
#ifdef EDITOR
|
||||||
strcpy(Powerup_names[n], &equal_ptr[1]);
|
auto &name = Powerup_names[n];
|
||||||
Powerup_names[n][strlen(Powerup_names[n])-1] = 0;
|
const auto len = strlen(equal_ptr);
|
||||||
|
assert(len < name.size()); // Oops, name too long.
|
||||||
|
memcpy(name.data(), &equal_ptr[1], len - 2);
|
||||||
|
name[len - 2] = 0;
|
||||||
|
#endif
|
||||||
} else if (!d_stricmp( arg, "size" )) {
|
} else if (!d_stricmp( arg, "size" )) {
|
||||||
Powerup_info[n].size = fl2f(atof(equal_ptr));
|
Powerup_info[n].size = fl2f(atof(equal_ptr));
|
||||||
} else {
|
} else {
|
||||||
|
|
|
@ -688,7 +688,7 @@ int robot_dialog_handler(UI_DIALOG *dlg,const d_event &event, robot_dialog *r)
|
||||||
Cur_goody_id = 0;
|
Cur_goody_id = 0;
|
||||||
case OBJ_POWERUP:
|
case OBJ_POWERUP:
|
||||||
type_text = "Powerup";
|
type_text = "Powerup";
|
||||||
id_text = Powerup_names[Cur_goody_id];
|
id_text = Powerup_names[Cur_goody_id].data();
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -137,7 +137,7 @@ static const char *object_ids(const vcobjptr_t objp)
|
||||||
case OBJ_ROBOT:
|
case OBJ_ROBOT:
|
||||||
return Robot_names[get_robot_id(objp)];
|
return Robot_names[get_robot_id(objp)];
|
||||||
case OBJ_POWERUP:
|
case OBJ_POWERUP:
|
||||||
return Powerup_names[get_powerup_id(objp)];
|
return Powerup_names[get_powerup_id(objp)].data();
|
||||||
}
|
}
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
|
|
|
@ -293,7 +293,7 @@ static void draw_window_label()
|
||||||
case OBJ_CAMERA: viewer_name = "Camera"; break;
|
case OBJ_CAMERA: viewer_name = "Camera"; break;
|
||||||
case OBJ_POWERUP: viewer_name = "Powerup";
|
case OBJ_POWERUP: viewer_name = "Powerup";
|
||||||
#ifdef EDITOR
|
#ifdef EDITOR
|
||||||
viewer_id = Powerup_names[get_powerup_id(vcobjptr(Viewer))];
|
viewer_id = Powerup_names[get_powerup_id(vcobjptr(Viewer))].data();
|
||||||
#endif
|
#endif
|
||||||
break;
|
break;
|
||||||
case OBJ_DEBRIS: viewer_name = "Debris"; break;
|
case OBJ_DEBRIS: viewer_name = "Debris"; break;
|
||||||
|
|
Loading…
Reference in a new issue