• There is NO official Otland's Discord server and NO official Otland's server list. The Otland's Staff does not manage any Discord server or server list. Moderators or administrator of any Discord server or server lists have NO connection to the Otland's Staff. Do not get scammed!
  • 2026 staff recruitment is open! Check it out and consider applying!

warning C4018: '>=': signed/unsigned mismatch

henkas

Well-Known Member
Joined
Jul 8, 2015
Messages
1,067
Solutions
5
Reaction score
63
Tfs 1.2
C++:
if (lastDay >= g_config.getNumber(ConfigManager::KILLS_DAY_RED_SKULL) ||
lastWeek >= g_config.getNumber(ConfigManager::KILLS_WEEK_RED_SKULL) ||
lastMonth >= g_config.getNumber(ConfigManager::KILLS_MONTH_RED_SKULL)) {
return 1; // red skull!
}

if (lastDay >= g_config.getNumber(ConfigManager::KILLS_DAY_BANISHMENT) ||
lastWeek >= g_config.getNumber(ConfigManager::KILLS_WEEK_BANISHMENT) ||
lastMonth >= g_config.getNumber(ConfigManager::KILLS_MONTH_BANISHMENT)) {
return 2; // banishment!
}
 
Solution
@Kaspar already provided You enough information how to solve this problem, but if You can't still figure it out, try to replace this code
C++:
uint32_t lastDay = 0;
uint32_t lastWeek = 0;
uint32_t lastMonth = 0;
uint64_t egibleMurders = 0;
with this
C++:
int32_t lastDay = 0;
int32_t lastWeek = 0;
int32_t lastMonth = 0;
int64_t egibleMurders = 0;
Not sure what you're asking for but I assume that you're wondering why you're getting a signed/unsigned mismatch.
IIRC it is because either lastDay/g_config is an unsigned int, whilst the other one is signed. You can't then apply the operator ">" to two operands of different signs.
 
Not sure what you're asking for but I assume that you're wondering why you're getting a signed/unsigned mismatch.
IIRC it is because either lastDay/g_config is an unsigned int, whilst the other one is signed. You can't then apply the operator ">" to two operands of different signs.
So its mistake in github who made this system lastDay/g_config is unsigned. Support to old frags skull system · mattyx14/otxserver@bbdfef2 (https://github.com/mattyx14/otxserver/commit/bbdfef26ad5e39e8d00cfb1118a65ed27a9c53da)
So the question is how to fix it then?
 
@Kaspar already provided You enough information how to solve this problem, but if You can't still figure it out, try to replace this code
C++:
uint32_t lastDay = 0;
uint32_t lastWeek = 0;
uint32_t lastMonth = 0;
uint64_t egibleMurders = 0;
with this
C++:
int32_t lastDay = 0;
int32_t lastWeek = 0;
int32_t lastMonth = 0;
int64_t egibleMurders = 0;
 
Solution
Replace this:
C++:
DBInsert murdersQuery("INSERT INTO [ICODE]player_murders[/ICODE]([ICODE]id[/ICODE], [ICODE]player_id[/ICODE], [ICODE]date[/ICODE]) VALUES ");
for (time_t timestamp : player->murderTimeStamps) {
    query << "NULL," << player->getGUID() << ',' << timestamp;
    if (!murdersQuery.addRow(query)) {
        return false;
    }
}
With this
C++:
DBInsert murdersQuery("INSERT INTO [ICODE]player_murders[/ICODE]([ICODE]player_id[/ICODE], [ICODE]date[/ICODE]) VALUES ");
for (time_t timestamp : player->murderTimeStamps) {
    query << player->getGUID() << ',' << timestamp;
    if (!murdersQuery.addRow(query)) {
        return false;
    }
}

and make sure that colum 'id' inside table 'player_murders' is set as primary key and has auto_increment

EDIT: those ICODE tags should be replaced with `
 
Last edited:
Back
Top