Issue information

Issue ID
#982
Status
Fixed
Severity
None
Started
Hercules Elf Bot
Feb 16, 2008 11:49
Last Post
Hercules Elf Bot
Feb 16, 2008 11:49
Confirmation
N/A

Hercules Elf Bot - Feb 16, 2008 11:49

Originally posted by [b]theultramage[/b]
http://www.eathena.ws/board/index.php?autocom=bugtracker&showbug=982

The base attack value is stored as an unsigned short. If you go crazy and allow high str values, around ~2500, the quadratic bonus will make status_base_atk() produce a value higher than 65k, which will cause an overflow when shoving the result into a 2-byte storage area.

One approach would be to change the batk type from unsigned short to unsigned int (and check all the related places for consistency).
The other would be to cap off this line
CODE
status->batk += status_base_atk(bl, status);
which is producing the unwanted result.

First attempt:
CODE
=== map/status.c
==================================================================
--- map/status.c    (revision 12206)

+++ map/status.c    (local)

@@ -1268,6 +1268,8 @@

//Fills in the misc data that can be calculated from the other status info (except for level)
void status_calc_misc(struct block_list *bl, struct status_data *status, int level)
{
+    int tmp;
+
    //Non players get the value set, players need to stack with previous bonuses.
    if (bl->type != BL_PC)
        status->batk =
@@ -1293,7 +1295,9 @@

    else
        status->flee2 = 0;

-    status->batk += status_base_atk(bl, status);
+    tmp = status->batk + status_base_atk(bl, status);
+    status->batk = cap_value(tmp, 0, 60000);
+
    if (status->cri)
    switch (bl->type) {
    case BL_MOB:



This post has been edited by theultramage: Feb 16 2008, 03:58 AM