armoha / euddraft

System for pluginizing eudplib codes.
Other
29 stars 4 forks source link

Better error for wrong size trigger field #103

Closed armoha closed 1 year ago

armoha commented 1 year ago
// epScript example
const a = Db(4);
CreateUnit(1, a, "loc", P1);  // Putting ConstExpr on Unit field
[1/3 단계] 오브젝트 수집
 - 오브젝트 2942 / 2942 수집
[2/3 단계] 오브젝트 할당
 - 오브젝트 2942 / 2942 전처리
 - 오브젝트 할당 중..
[3/3 단계] 페이로드 구성
Traceback (most recent call last):
  File "eudplib\core\allocator\constexpr.pyx", line 216, in eudplib.core.allocator.constexpr.Evaluate
  File "eudplib\core\allocator\constexpr.pyx", line 221, in eudplib.core.allocator.constexpr.Evaluate
  File "eudplib\core\allocator\constexpr.pyx", line 52, in eudplib.core.allocator.constexpr.ConstExpr.Evaluate
  File "eudplib\core\allocator\constexpr.pyx", line 53, in eudplib.core.allocator.constexpr.ConstExpr.Evaluate
  File "eudplib\core\allocator\constexpr.pyx", line 52, in eudplib.core.allocator.constexpr.ConstExpr.Evaluate
  File "E:\P\lib\site-packages\eudplib-0.69.8-py3.10-win-amd64.egg\eudplib\core\eudobj\eudobj.py", line 72, in Evaluate
  File "E:\P\lib\site-packages\eudplib-0.69.8-py3.10-win-amd64.egg\eudplib\core\allocator\payload.py", line 434, in GetObjectAddr
KeyError: <eudplib.core.eudobj.bytedump.Db object at 0x000001EF449D10D0>
Exception ignored in: 'eudplib.core.allocator.pbuffer._StructPacker'
==========================================
[Error] obj.GetDataSize()(2408) 가 실제 페이로드 크기(2376) 와 오브젝트 <eudplib.core.rawtrigger.rawtriggerdef.RawTrigger object at 0x0000028EA3CC3970> 에서 일치하지 않습니다 Traceback (most recent call last):
  File "E:\euddraft\applyeuddraft.py", line 180, in applyEUDDraft
    ep.CompressPayload(True)
  File "E:\P\lib\site-packages\eudplib-0.69.8-py3.10-win-amd64.egg\eudplib\maprw\savemap.py", line 73, in SaveMap
  File "E:\P\lib\site-packages\eudplib-0.69.8-py3.10-win-amd64.egg\eudplib\maprw\injector\applyInjector.py", line 58, in applyInjector
  File "E:\P\lib\site-packages\eudplib-0.69.8-py3.10-win-amd64.egg\eudplib\core\allocator\payload.py", line 403, in CreatePayload
  File "E:\P\lib\site-packages\eudplib-0.69.8-py3.10-win-amd64.egg\eudplib\core\allocator\payload.py", line 376, in ConstructPayload
  File "E:\P\lib\site-packages\eudplib-0.69.8-py3.10-win-amd64.egg\eudplib\utils\eperror.py", line 41, in ep_assert
eudplib.utils.eperror.EPError: obj.GetDataSize()(2408) 가 실제 페이로드 크기(2376) 와 오브젝트 <eudplib.core.rawtrigger.rawtriggerdef.RawTrigger object at 0x0000028EA3CC3970> 에서 일치하지 않습니다

The error is not catched until writing phase, hard to find where to look at.

armoha commented 1 year ago

Fixed by https://github.com/armoha/eudplib/commit/037eb39a45a82bfafc0ba5f4889b1c9539d27715#diff-84dafc6075c6863ee30e287caacce8dbdc9df34773177e8668df97b68a58ec49R155-R159

>>> a = Db(4)
>>> DoActions(CreateUnit(1, a, "Anywhere", P1))
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "E:\eudplib\eudplib\ctrlstru\basicstru.py", line 33, in DoActions
    return tg.Trigger(actions=actions, preserved=preserved)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "E:\eudplib\eudplib\trigger\triggerdef.py", line 71, in Trigger
    tend = c.RawTrigger(conditions=patched_conds, actions=patched_actions, preserved=preserved)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "E:\eudplib\eudplib\core\rawtrigger\rawtriggerdef.py", line 154, in __init__
    act.CheckArgs(i)
  File "E:\eudplib\eudplib\core\rawtrigger\action.py", line 231, in CheckArgs
    raise ut.EPError("\n".join(error))
eudplib.utils.eperror.EPError: Invalid fields for action0 CreateUnit:
        invalid unit_type: <eudplib.core.eudobj.bytedump.Db object at 0x0000018D9DC1F390>