MillhioreBT / forgottenserver-downgrade

TFS Downgrade 1.5+ is an engine based on nekiro downgrade but highly updated with current tfs code, it also has the lua modules divided and uses lua5.4
GNU General Public License v2.0
19 stars 18 forks source link

Server crashes due to NULL ptr #6

Closed xmish closed 1 year ago

xmish commented 1 year ago

Before creating an issue, please ensure:

Steps to reproduce (include any configuration/script required to reproduce)

  1. Login 1 GM
  2. Login 1 Player
  3. Walk a bit next to temple

Expected behaviour

Actual behaviour

image

attacker is NULL https://github.com/MillhioreBT/forgottenserver-downgrade/blob/bac4f90e34465fce6b4e0b0efbd609ef527ffa8e/src/creature.cpp#L879

getCreatureByID() gives nullptr as owner is equal 0: https://github.com/MillhioreBT/forgottenserver-downgrade/blob/bac4f90e34465fce6b4e0b0efbd609ef527ffa8e/src/condition.cpp#L1361

Environment

Windows 10 Pro 22H2

Reproduction environment

xmish commented 1 year ago

Aaa ok it's probably due to the condition that player has as doDamage does that for the player: healthChange = -2

{primary={type=COMBAT_EARTHDAMAGE (4) value=-2 } secondary={type=COMBAT_NONE (0) value=0 } origin=ORIGIN_CONDITION (1) ...}
    primary: {type=COMBAT_EARTHDAMAGE (4) value=-2 }
    secondary: {type=COMBAT_NONE (0) value=0 }
    origin: ORIGIN_CONDITION (1)
    blockType: BLOCK_NONE (0 '\0')
    critical: false
    leeched: false

Database condition to reproduce:

INSERT INTO mb.players (name,group_id,account_id,`level`,vocation,health,healthmax,experience,lookbody,lookfeet,lookhead,looklegs,looktype,lookaddons,direction,maglevel,mana,manamax,manaspent,soul,town_id,posx,posy,posz,conditions,cap,sex,lastlogin,lastip,save,skull,skulltime,lastlogout,blessings,onlinetime,deletion,balance,stamina,skill_fist,skill_fist_tries,skill_club,skill_club_tries,skill_sword,skill_sword_tries,skill_axe,skill_axe_tries,skill_dist,skill_dist_tries,skill_shielding,skill_shielding_tries,skill_fishing,skill_fishing_tries) VALUES
     ('GM',6,2,1337,1,150,150,39654617600,0,0,0,0,136,0,1,0,0,0,0,0,1,95,128,7,0x,400,0,1685321026,16777343,1,0,0,1685321089,0,434,0,0,2520,10,0,10,0,10,0,10,0,10,0,10,0,10,0),
     ('x',1,3,1337,1,96,150,39654617600,0,0,0,0,136,0,1,0,0,0,0,0,1,92,130,7,0x010004000002FFFFFFFF0360EA00001A001B000000001C00FE0101000000020000000003803801001A001B000000001C00080119000000000AD0070000FEFFFFFFA00F00000AA00F0000FEFFFFFFA00F00000AA00F0000FEFFFFFFA00F00000AA00F0000FFFFFFFFA00F00000AA00F0000FFFFFFFFA00F00000AA00F0000FFFFFFFFA00F00000AA00F0000FFFFFFFFA00F00000AA00F0000FFFFFFFFA00F00000AA00F0000FFFFFFFFA00F00000AA00F0000FFFFFFFFA00F00000AA00F0000FFFFFFFFA00F00000AA00F0000FFFFFFFFA00F00000AA00F0000FFFFFFFFA00F00000AA00F0000FFFFFFFFA00F00000AA00F0000FFFFFFFFA00F00000AA00F0000FFFFFFFFA00F00000AA00F0000FFFFFFFFA00F00000AA00F0000FFFFFFFFA00F00000AA00F0000FFFFFFFFA00F00000AA00F0000FFFFFFFFA00F0000FE,400,0,1685320921,16777343,1,0,0,1685321089,0,239,0,0,2520,10,0,10,0,10,0,10,0,10,0,10,0,10,0);

It's character with name x

Or even easier:

MillhioreBT commented 1 year ago

Aaa ok it's probably due to the condition that player has as doDamage does that for the player: healthChange = -2

{primary={type=COMBAT_EARTHDAMAGE (4) value=-2 } secondary={type=COMBAT_NONE (0) value=0 } origin=ORIGIN_CONDITION (1) ...}
    primary: {type=COMBAT_EARTHDAMAGE (4) value=-2 }
    secondary: {type=COMBAT_NONE (0) value=0 }
    origin: ORIGIN_CONDITION (1)
    blockType: BLOCK_NONE (0 '\0')
    critical: false
    leeched: false

Database condition to reproduce:

INSERT INTO mb.players (name,group_id,account_id,`level`,vocation,health,healthmax,experience,lookbody,lookfeet,lookhead,looklegs,looktype,lookaddons,direction,maglevel,mana,manamax,manaspent,soul,town_id,posx,posy,posz,conditions,cap,sex,lastlogin,lastip,save,skull,skulltime,lastlogout,blessings,onlinetime,deletion,balance,stamina,skill_fist,skill_fist_tries,skill_club,skill_club_tries,skill_sword,skill_sword_tries,skill_axe,skill_axe_tries,skill_dist,skill_dist_tries,skill_shielding,skill_shielding_tries,skill_fishing,skill_fishing_tries) VALUES
   ('GM',6,2,1337,1,150,150,39654617600,0,0,0,0,136,0,1,0,0,0,0,0,1,95,128,7,0x,400,0,1685321026,16777343,1,0,0,1685321089,0,434,0,0,2520,10,0,10,0,10,0,10,0,10,0,10,0,10,0),
   ('x',1,3,1337,1,96,150,39654617600,0,0,0,0,136,0,1,0,0,0,0,0,1,92,130,7,0x010004000002FFFFFFFF0360EA00001A001B000000001C00FE0101000000020000000003803801001A001B000000001C00080119000000000AD0070000FEFFFFFFA00F00000AA00F0000FEFFFFFFA00F00000AA00F0000FEFFFFFFA00F00000AA00F0000FFFFFFFFA00F00000AA00F0000FFFFFFFFA00F00000AA00F0000FFFFFFFFA00F00000AA00F0000FFFFFFFFA00F00000AA00F0000FFFFFFFFA00F00000AA00F0000FFFFFFFFA00F00000AA00F0000FFFFFFFFA00F00000AA00F0000FFFFFFFFA00F00000AA00F0000FFFFFFFFA00F00000AA00F0000FFFFFFFFA00F00000AA00F0000FFFFFFFFA00F00000AA00F0000FFFFFFFFA00F00000AA00F0000FFFFFFFFA00F00000AA00F0000FFFFFFFFA00F00000AA00F0000FFFFFFFFA00F00000AA00F0000FFFFFFFFA00F00000AA00F0000FFFFFFFFA00F0000FE,400,0,1685320921,16777343,1,0,0,1685321089,0,239,0,0,2520,10,0,10,0,10,0,10,0,10,0,10,0,10,0);

It's character with name x

Or even easier:

  • get a player
  • spawn cobra and let it poison player
  • /kick player
  • relogin player
  • crash

Thanks for the report. I'll try it and fix it later.

xmish commented 1 year ago

https://github.com/otland/forgottenserver/commit/c82d3329c73e51e1ab8d45a97276eeacc4b38a11

https://github.com/MillhioreBT/forgottenserver-downgrade/commit/0aff6b7b9647d0bfc76f814e1752c926aa9a5bf3/src/creature.cpp#L875

MillhioreBT commented 1 year ago

image fixed.

Could you not combine two problems in the same Issue? it's confusing

xmish commented 1 year ago

It was actually the same issue, but i just later realized that it was caused by condition, the player that I logged on had this condition, so issue had nothing with GM

MillhioreBT commented 1 year ago

The problem has already been fixed, if it still persists feel free to reopen the issue.