mirror of
https://github.com/pmret/papermario.git
synced 2024-11-08 12:02:30 +01:00
rename enums
This commit is contained in:
parent
0d8814555e
commit
46c2016bf1
2692
include/enums.h
2692
include/enums.h
File diff suppressed because it is too large
Load Diff
@ -30,11 +30,11 @@ void func_80137E4C(s32, s32, s32, s32);
|
||||
s32 rand_int(s32);
|
||||
void sort_items(void);
|
||||
s32 is_ability_active(s32 arg0);
|
||||
f32 update_lerp(EASING easing, f32 start, f32 end, s32 elapsed, s32 duration);
|
||||
f32 update_lerp(Easing easing, f32 start, f32 end, s32 elapsed, s32 duration);
|
||||
|
||||
Npc* get_npc_safe(s32 npcID);
|
||||
Npc* get_npc_unsafe(s32 npcID);
|
||||
Npc* resolve_npc(Script* script, NPC npcID);
|
||||
Npc* get_npc_safe(NpcId npcId);
|
||||
Npc* get_npc_unsafe(NpcId npcId);
|
||||
Npc* resolve_npc(Script* script, NpcId npcIdOrPtr);
|
||||
|
||||
f32 dist2D(f32 ax, f32 ay, f32 bx, f32 by);
|
||||
f32 dist3D(f32 ax, f32 ay, f32 az, f32 bx, f32 by, f32 bz);
|
||||
|
@ -42,9 +42,9 @@ INCLUDE_ASM(code_13870_len_6980, render_npcs);
|
||||
|
||||
INCLUDE_ASM(code_13870_len_6980, npc_move_heading);
|
||||
|
||||
Npc* INCLUDE_ASM(code_13870_len_6980, get_npc_unsafe, s32 npcID);
|
||||
Npc* INCLUDE_ASM(code_13870_len_6980, get_npc_unsafe, NpcId npcId);
|
||||
|
||||
Npc* INCLUDE_ASM(code_13870_len_6980, get_npc_safe, s32 npcID);
|
||||
Npc* INCLUDE_ASM(code_13870_len_6980, get_npc_safe, NpcId npcId);
|
||||
|
||||
INCLUDE_ASM(code_13870_len_6980, enable_npc_shadow);
|
||||
|
||||
|
@ -78,7 +78,7 @@ f32 INCLUDE_ASM(code_42e0_len_1f60, sin_deg, f32 x);
|
||||
|
||||
f32 INCLUDE_ASM(code_42e0_len_1f60, cos_deg, f32 x);
|
||||
|
||||
f32 INCLUDE_ASM(code_42e0_len_1f60, update_lerp, EASING easing, f32 start, f32 end, s32 elapsed, s32 duration);
|
||||
f32 INCLUDE_ASM(code_42e0_len_1f60, update_lerp, Easing easing, f32 start, f32 end, s32 elapsed, s32 duration);
|
||||
|
||||
INCLUDE_ASM(code_42e0_len_1f60, func_8002A904);
|
||||
|
||||
|
@ -1,12 +1,12 @@
|
||||
#include "common.h"
|
||||
|
||||
Npc* resolve_npc(Script* script, NPC npcID) {
|
||||
if (npcID == NPC_SELF) {
|
||||
Npc* resolve_npc(Script* script, NpcId npcIdOrPtr) {
|
||||
if (npcIdOrPtr == NpcId_SELF) {
|
||||
return get_npc_safe(script->ownerID);
|
||||
} else if (npcID >= -270000000) {
|
||||
return get_npc_safe(npcID);
|
||||
} else if (npcIdOrPtr >= -270000000) {
|
||||
return get_npc_safe(npcIdOrPtr);
|
||||
} else {
|
||||
return (Npc*) npcID;
|
||||
return (Npc*) npcIdOrPtr;
|
||||
}
|
||||
}
|
||||
|
||||
@ -25,7 +25,7 @@ s32 DeleteNpc(Script* script, s32 initialCall) {
|
||||
|
||||
s32 GetNpcPointer(Script* script, s32 initialCall) {
|
||||
Bytecode* ptrReadPos = script->ptrReadPos;
|
||||
Bytecode npcID = get_variable(script, *ptrReadPos++);
|
||||
NpcId npcID = get_variable(script, *ptrReadPos++);
|
||||
Bytecode varNPC = *ptrReadPos++;
|
||||
|
||||
set_variable(script, varNPC, get_npc_safe(npcID));
|
||||
|
@ -45,8 +45,8 @@ s32 RandInt(Script* script, s32 initialCall) {
|
||||
s32 GetAngleBetweenNPCs(Script* script, s32 initialCall) {
|
||||
Bytecode* ptrReadPos = script->ptrReadPos;
|
||||
|
||||
NPC aID = get_variable(script, *ptrReadPos++);
|
||||
NPC bID = get_variable(script, *ptrReadPos++);
|
||||
NpcId aID = get_variable(script, *ptrReadPos++);
|
||||
NpcId bID = get_variable(script, *ptrReadPos++);
|
||||
Bytecode outVar = *ptrReadPos++;
|
||||
|
||||
Npc* a = resolve_npc(script, aID);
|
||||
@ -60,7 +60,7 @@ s32 GetAngleToNPC(Script* script, s32 initialCall) {
|
||||
PlayerStatus* playerStatus = &gPlayerStatus;
|
||||
Bytecode* ptrReadPos = script->ptrReadPos;
|
||||
|
||||
NPC npcID = get_variable(script, *ptrReadPos++);
|
||||
NpcId npcID = get_variable(script, *ptrReadPos++);
|
||||
Bytecode outVar = *ptrReadPos++;
|
||||
|
||||
Npc* npc = resolve_npc(script, npcID);
|
||||
@ -73,7 +73,7 @@ s32 GetAngleToPlayer(Script* script, s32 initialCall) {
|
||||
PlayerStatus* playerStatus = &gPlayerStatus;
|
||||
Bytecode* ptrReadPos = script->ptrReadPos;
|
||||
|
||||
NPC npcID = get_variable(script, *ptrReadPos++);
|
||||
NpcId npcID = get_variable(script, *ptrReadPos++);
|
||||
Bytecode outVar = *ptrReadPos++;
|
||||
|
||||
Npc* npc = resolve_npc(script, npcID);
|
||||
|
@ -114,7 +114,7 @@ s32 AddKeyItem(Script* script, s32 initialCall) {
|
||||
s32 itemID = get_variable(script, value);
|
||||
s32 i;
|
||||
|
||||
if (itemID == ITEM_FORTRESS_KEY) {
|
||||
if (itemID == ItemId_FORTRESS_KEY) {
|
||||
playerData->fortressKeyCount++;
|
||||
return 2;
|
||||
}
|
||||
|
@ -3,7 +3,7 @@
|
||||
import os
|
||||
import re
|
||||
from glob import glob
|
||||
from stringcase import constcase # pip install stringcase
|
||||
from stringcase import constcase, pascalcase # pip install stringcase
|
||||
|
||||
DIR = os.path.dirname(__file__)
|
||||
SR_DATABASE = os.path.join(DIR, "star-rod/database")
|
||||
@ -19,7 +19,7 @@ with open(os.path.join(DIR, "../include/enums.h"), "w") as h:
|
||||
#define _ENUMS_H_
|
||||
|
||||
#include "ultra64.h"
|
||||
#include "types.h"
|
||||
#include "types.h"
|
||||
|
||||
""")
|
||||
|
||||
@ -28,10 +28,27 @@ with open(os.path.join(DIR, "../include/enums.h"), "w") as h:
|
||||
lines = file.readlines()
|
||||
|
||||
# Get enum attributes
|
||||
namespace = constcase(re.match(r"[^ \t]*", lines[0]).group(0))
|
||||
namespace = pascalcase(re.match(r"[^ \t]*", lines[0]).group(0))
|
||||
library_name = re.match(r"[^ \t]*", lines[1]).group(0)
|
||||
reverse = True if re.match(r"[^ \t]*", lines[2]).group(0) == "true" else False
|
||||
|
||||
# Renamed namespaces
|
||||
if namespace == "Item": namespace = "ItemId"
|
||||
if namespace == "Sound": namespace = "SoundId"
|
||||
if namespace == "Partner": namespace = "PartnerId"
|
||||
if namespace == "Sprite": namespace = "SpriteId"
|
||||
if namespace == "Outcome": namespace = "EncounterOutcome"
|
||||
#if namespace == "Phase": namespace = "BattlePhase"
|
||||
if namespace == "Actor": namespace = "ActorId"
|
||||
#if namespace == "Status": namespace = "ActorStatus"
|
||||
#if namespace == "StatusFlags": namespace = "ActorStatusFlags"
|
||||
#if namespace == "Event": namespace = "BattleEvent"
|
||||
if namespace == "Decoration": namespace = "DecorationId"
|
||||
if namespace == "Npc": namespace = "NpcId"
|
||||
if namespace == "Trigger": namespace = "TriggerFlags"
|
||||
if namespace == "Anim": continue
|
||||
if namespace == "Entity": continue # just ram addresses
|
||||
|
||||
# Get a list of tuples containing (name, value)
|
||||
items = []
|
||||
name_max_len = 0
|
||||
@ -51,8 +68,9 @@ with open(os.path.join(DIR, "../include/enums.h"), "w") as h:
|
||||
str_value = f"{value}"
|
||||
else:
|
||||
str_value = "0x" + f"{value:08x}".upper()
|
||||
|
||||
name = constcase(name)
|
||||
|
||||
if name.upper() != name:
|
||||
name = constcase(name)
|
||||
items.append((name, str_value))
|
||||
name_max_len = max(len(name), name_max_len)
|
||||
elif "/%" in line:
|
||||
@ -66,4 +84,4 @@ with open(os.path.join(DIR, "../include/enums.h"), "w") as h:
|
||||
h.write(f"#define {namespace}_{name.ljust(name_max_len)} {value}\n")
|
||||
h.write("\n")
|
||||
|
||||
h.write("#endif\n")
|
||||
h.write("#endif\n")
|
||||
|
Loading…
Reference in New Issue
Block a user