To solve the first warning regarding '*', try this modification:
GET_SECONDS_PLAYED(victim) / (double)(current_time-victim->player_id) * 100
To solve the second warning, show the problematic line more exactly.
This browser is no longer supported.
Upgrade to Microsoft Edge to take advantage of the latest features, security updates, and technical support.
I'm getting the following error:
Warning C26451 Arithmetic overflow: Using operator '*' on a 4 byte value and then casting the result to a 8 byte value. Cast the value to the wider type before calling operator '*' to avoid overflow (io.2). testROS_1a C:_Reign of Shadow\TEST\src\CPP\act_wiz.cpp 2247
This is what I'm working with (I'll try to give you only the relevant parts):
chardata.h
class char_data : public entity_data
{
public: entity_type get_entitytype() {return ENTITYTYPE_CH;};
public:
// member functions
// output to character
void printf(const char *fmt, ...) __mftc_printf_1__;
...
void printf(int seconds, const char *fmt, ...) __mftc_printf_2__;
...
void printlnf(const char *fmt, ...) __mftc_printf_1__;
...
void printlnf(int seconds, const char *fmt, ...) __mftc_printf_2__;
...
macros.h
#define GET_SECONDS_PLAYED(ch) \(ch->played + (int) (current_time - ch->logon))
#define GET_AGE(ch) ((int) (17 + ((ch)->played \+ current_time - (ch)->logon )/72000))
not sure how "\+" works but that's not a typo
act_wiz.cpp
void do_charinfo( char_data *ch, char *argument )
{
...
char_data *victim;
(this is where the error occurs)
ch->printf(" Age: %-3d Played: %d(%0.03f%%) LastLevel: %-4d ",
GET_AGE(victim),
(int) (GET_SECONDS_PLAYED(victim)/ 3600),
GET_SECONDS_PLAYED(victim)* 100/ (double)(current_time-victim->player_id),
victim->pcdata->last_level);
it says the error is on line 4 highlighting "GET_SECONDS_PLAYED(victim)* 100" and "(current_time-victim->"
There's several more. Here are a few more examples:
Warning C26451 Arithmetic overflow: Using operator '+' on a 4 byte value and then casting the result to a 8 byte value. Cast the value to the wider type before calling operator '+' to avoid overflow (io.2). testROS_1a C:_Reign of Shadow\TEST\src\CPP\act_wiz.cpp 2247
(notice the + instead of the *)
ch->printf(" Age: %-3d Played: %d(%0.03f%%) LastLevel: %-4d ",
GET_AGE(victim),
(int) (GET_SECONDS_PLAYED(victim)/ 3600),
GET_SECONDS_PLAYED(victim)* 100/ (double)(current_time-victim->player_id),
victim->pcdata->last_level);
...
add_mana = (ch->perm_stats[STAT_PR] +
ch->perm_stats[STAT_EM] +
ch->perm_stats[STAT_IN] + 35.0) / 20.0;
I tried a few of the examples here but none of them worked. Admittedly, I may have just been doing it wrong.
Any ideas?
To solve the first warning regarding '*', try this modification:
GET_SECONDS_PLAYED(victim) / (double)(current_time-victim->player_id) * 100
To solve the second warning, show the problematic line more exactly.