Skip to content

Commit 29edfee

Browse files
committed
display category name
1 parent 8cf20b0 commit 29edfee

File tree

3 files changed

+18
-2
lines changed

3 files changed

+18
-2
lines changed

code/parse/sexp.cpp

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -32318,6 +32318,21 @@ int get_category(int sexp_id)
3231832318
return category;
3231932319
}
3232032320

32321+
// Goober5000
32322+
const char *get_category_name(int category_id)
32323+
{
32324+
if (category_id == OP_CATEGORY_CHANGE2)
32325+
category_id = OP_CATEGORY_CHANGE;
32326+
32327+
for (auto &category : op_menu)
32328+
{
32329+
if (category.id == category_id)
32330+
return category.name.c_str();
32331+
}
32332+
32333+
return "<unknown>";
32334+
}
32335+
3232132336
// Goober5000
3232232337
int category_of_subcategory(int subcategory_id)
3232332338
{

code/parse/sexp.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1359,6 +1359,7 @@ void set_turret_secondary_ammo(ship_subsys *turret, int requested_bank, int requ
13591359
extern int get_category(int sexp_id);
13601360
extern int category_of_subcategory(int subcategory_id);
13611361
extern int get_subcategory(int sexp_id);
1362+
extern const char *get_category_name(int category_id);
13621363

13631364
// Goober5000
13641365
extern void sexp_music_close();

code/parse/sexp/sexp_lookup.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -181,12 +181,12 @@ int add_dynamic_sexp(std::unique_ptr<DynamicSEXP>&& sexp, int type)
181181

182182
int free_op_index = get_next_free_operator(sexp->getCategory());
183183
if (free_op_index >= 256) {
184-
Warning(LOCATION, "There are too many SEXPs in the category %d. The %s SEXP will not be added.", sexp->getCategory(), sexp->getName().c_str());
184+
Warning(LOCATION, "There are too many SEXPs in the %s category. The SEXP %s will not be added.", get_category_name(sexp->getCategory()), sexp->getName().c_str());
185185
return -1;
186186
}
187187

188188
if (Operators.size() >= FIRST_OP) {
189-
Warning(LOCATION, "There are too many total SEXPs. The %s SEXP will not be added.", sexp->getName().c_str());
189+
Warning(LOCATION, "There are too many total SEXPs. The SEXP %s will not be added.", sexp->getName().c_str());
190190
return -1;
191191
}
192192

0 commit comments

Comments
 (0)