Tíquete #57670

3.1: no LUA signals for some actions

: 2024-04-16 05:15 Última Atualização: 2024-05-24 03:08

Relator:
Dono:
Tipo:
Estado:
Fechado
Componente:
Marcos:
Prioridade:
5 - Medium
Gravidade:
5 - Medium
Resolução:
Fixed
Arquivo:
4

Details

There are no LUA signals in 3.1 for the actions: Pillage, Fortify, and Convert Unit.

I don't know if this is intended, or a bug. I can't compile and test the trunk right now to see if they work there.

I mean that this LUA script will never be triggered:

function action_started_callback(action, actor, target)
  if action:rule_name() == "Fortify" then
    --never triggered...
  elseif action:rule_name() == "Pillage" then
    --never triggered...
  end
end

signal.connect("action_started_unit_self", "action_started_callback")
signal.connect("action_started_unit_tile", "action_started_callback")

Ticket History (3/13 Histories)

2024-04-16 05:15 Updated by: bard
  • New Ticket "3.1: no LUA signals for some actions" created
2024-04-16 05:57 Updated by: cazfi
Comentário

This (at least the Pillage case, which I investigated) is more serious than just missing lua signal. The usual way in the client UI to request Pillage results just in a change of unit's *activity*, skipping all *actions* related stuff. If you specifically select "Go to and ... Pillage" (action), also the lua script runs.

2024-04-16 06:21 Updated by: cazfi
  • Dono Update from (Nenhum) to cazfi
  • Resolução Update from Nenhum to Accepted
  • Marco Update from (Nenhum) to 3.1.2 (fechado)
  • Componente Update from Scripting API to Server
2024-04-17 06:31 Updated by: cazfi
Comentário

The fix exposes https://redmine.freeciv.org/issues/460, leading to a crash there. Need to fix it before this one.

2024-04-17 06:41 Updated by: cazfi
Comentário

- Fix crash when the pillage target is not preset

2024-04-20 06:14 Updated by: bard
Comentário

I didn't plan to report the following because I thought it was caused by a bad use of the scripts, but just in case it could be related to this bug...

When I use a LUA script, triggered by a finished action signal, and the script kills the actor or forces him to disband (I tested different action triggers and different ways to kill the actor), then if the actor unit is being transported, there is a crash with the error:

in utype_can_do_action() [unittype.c::449]: assertion '(signed int)(utype_index(putype)) >= 0 && (signed int)(utype_index(putype)) < (signed int) sizeof((unit_can_act_cacheact_id).vec) * 8' failed.

The script:

function action_finished_callback(action, success, actor, target)
  if action:rule_name() == "Heal Unit" then
    if success then
      -- FIXME: this crashes when healer is being transported
      actor:kill("used",Nil)
    end
  end
end

2024-05-04 19:08 Updated by: cazfi
Comentário

Reply To bard

I didn't plan to report the following because I thought it was caused by a bad use of the scripts, but just in case it could be related to this bug... When I use a LUA script, triggered by a finished action signal, and the script kills the actor or forces him to disband (I tested different action triggers and different ways to kill the actor), then if the actor unit is being transported, there is a crash with the error: in utype_can_do_action() [unittype.c::449]: assertion '(signed int)(utype_index(putype)) >= 0 && (signed int)(utype_index(putype)) < (signed int) sizeof((unit_can_act_cacheact_id).vec) * 8' failed. The script: {{{ function action_finished_callback(action, success, actor, target) if action:rule_name() == "Heal Unit" then if success then -- FIXME: this crashes when healer is being transported actor:kill("used",Nil) end end end }}}

I could not reproduce this. Please open a new ticket if you still can reproduce it yourself.

2024-05-05 08:39 Updated by: bard
Comentário

Reply To cazfi

I could not reproduce this. Please open a new ticket if you still can reproduce it yourself.

Ok, I'll try to upload a savegame (+ruleset) to a new ticket.

2024-05-24 03:08 Updated by: cazfi
  • Estado Update from Aberto to Fechado
  • Resolução Update from Accepted to Fixed

Editar

Please login to add comment to this ticket » Login