use static instead of anon namespace; suggested changes

develop
Ryan Williams 2022-05-30 13:51:24 -07:00 committed by GitHub
parent 1c3ea000e1
commit 0ff0d272b5
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 73 additions and 80 deletions

@ -140,7 +140,7 @@ namespace DFHack
// Recenter the viewscreen, based on DF code for announcements and scrolling
DFHACK_EXPORT void pauseRecenter(int32_t x, int32_t y, int32_t z, bool pause);
DFHACK_EXPORT inline void pauseRecenter(df::coord pos, bool pause) { return pauseRecenter(pos.x, pos.y, pos.z, pause); }
DFHACK_EXPORT inline void pauseRecenter(df::coord pos, bool pause) { pauseRecenter(pos.x, pos.y, pos.z, pause); }
DFHACK_EXPORT void recenterViewscreen(int32_t x, int32_t y, int32_t z, df::report_zoom_type zoom = df::enums::report_zoom_type::Item);
DFHACK_EXPORT inline void recenterViewscreen(df::coord pos, df::report_zoom_type zoom = df::enums::report_zoom_type::Item) { recenterViewscreen(pos.x, pos.y, pos.z, zoom); };
DFHACK_EXPORT inline void recenterViewscreen(df::report_zoom_type zoom = df::enums::report_zoom_type::Item) { recenterViewscreen(getCursorPos(), zoom); };

@ -1368,9 +1368,8 @@ DFHACK_EXPORT void Gui::writeToGamelog(std::string message)
fseed.close();
}
namespace
{ // Utility functions for reports
bool parseReportString(std::vector<std::string> *out, const std::string &str, size_t line_length = 73)
// Utility functions for reports
static bool parseReportString(std::vector<std::string> *out, const std::string &str, size_t line_length = 73)
{ // parse a string into output strings like DF does for reports
if (str.empty() || line_length == 0)
return false;
@ -1388,7 +1387,7 @@ namespace
if (str[i] == 'r') // "&r" adds a blank line
{
word_wrap(out, parsed, line_length, false/*, true*/);
word_wrap(out, parsed, line_length/*, WSMODE_TRIM_LEADING*/);
out->push_back(" "); // DF adds a line with a space for some reason
parsed.clear();
}
@ -1402,23 +1401,19 @@ namespace
while (++i < str.length());
if (parsed.length())
word_wrap(out, parsed, line_length, false/*, true*/);
word_wrap(out, parsed, line_length/*, WSMODE_TRIM_LEADING*/);
return true;
}
bool recent_report(df::unit *unit, df::unit_report_type slot)
static bool recent_report(df::unit *unit, df::unit_report_type slot)
{
if (unit && !unit->reports.log[slot].empty() &&
return unit && !unit->reports.log[slot].empty() &&
*df::global::cur_year == unit->reports.last_year[slot] &&
(*df::global::cur_year_tick - unit->reports.last_year_tick[slot]) <= 500)
{
return true;
}
return false;
(*df::global::cur_year_tick - unit->reports.last_year_tick[slot]) <= 500;
}
bool recent_report_any(df::unit *unit)
static bool recent_report_any(df::unit *unit)
{
FOR_ENUM_ITEMS(unit_report_type, slot)
{
@ -1428,7 +1423,7 @@ namespace
return false;
}
void delete_old_reports()
static void delete_old_reports()
{
auto &reports = world->status.reports;
while (reports.size() > 3000)
@ -1443,7 +1438,7 @@ namespace
}
}
int32_t check_repeat_report(vector<string> &results)
static int32_t check_repeat_report(vector<string> &results)
{ // returns the new repeat count, else 0
if (*gamemode == game_mode::DWARF && !results.empty() && world->status.reports.size() >= results.size())
{
@ -1460,7 +1455,7 @@ namespace
}
return 0;
}
}
// End of utility functions for reports
DFHACK_EXPORT int Gui::makeAnnouncement(df::announcement_type type, df::announcement_flags flags, df::coord pos, std::string message, int color, bool bright)
{
@ -1592,9 +1587,8 @@ bool Gui::addCombatReport(df::unit *unit, df::unit_report_type slot, int report_
return true;
}
namespace
{ // An additional utility function for reports
bool add_proper_report(df::unit *unit, bool is_sparring, int report_index)
// An additional utility function for reports
static bool add_proper_report(df::unit *unit, bool is_sparring, int report_index)
{
if (is_sparring)
return Gui::addCombatReport(unit, unit_report_type::Sparring, report_index);
@ -1603,7 +1597,6 @@ namespace
else
return Gui::addCombatReport(unit, unit_report_type::Combat, report_index);
}
}
bool Gui::addCombatReportAuto(df::unit *unit, df::announcement_flags mode, int report_index)
{