Return-To-The-Roots / s25client

Return To The Roots (Settlers II(R) Clone)
http://www.rttr.info
GNU General Public License v2.0
476 stars 75 forks source link

#1176 onAttack for lua #1570

Closed ottml closed 1 year ago

ottml commented 1 year ago

Fixes #1176

Flamefire commented 1 year ago

@Flow86 What's up with Jenkins?

Flow86 commented 1 year ago

@Flow86 What's up with Jenkins?

some of the packages seem to be broken, I'll try to renovate the pipeline (to get a newer cross compiler etc) but this will take a while

JarnoNL79 commented 1 year ago

In the gameworld.cpp file the lua onAttack event is added to the GameWorld::Attack, if I understand the code correctly this is only for land attacks and there's a seperate method / function to do sea attacks, the GameWorld::AttackViaSea the lua event seems to be missing from there.

I could misinterpret the code, but I think adding the code below after line 836 should do the trick (could be something I missed for the harbour instead of building)

    if(counter > 0 && HasLua())
    {
        GetLua().EventAttack(player_attacker, attacked_building->GetPlayer(), counter );
    }
ottml commented 1 year ago

In the gameworld.cpp file the lua onAttack event is added to the GameWorld::Attack, if I understand the code correctly this is only for land attacks and there's a seperate method / function to do sea attacks, the GameWorld::AttackViaSea the lua event seems to be missing from there.

I could misinterpret the code, but I think adding the code below after line 836 should do the trick (could be something I missed for the harbour instead of building)

    if(counter > 0 && HasLua())
    {
        GetLua().EventAttack(player_attacker, attacked_building->GetPlayer(), counter );
    }

Added the missing call to seaAttack too.

ottml commented 1 year ago

@Flow86 Can you review and approve and merge if everything is okay. Thanks