Skip to content

Instantly share code, notes, and snippets.

@garrettjoecox
Last active September 5, 2023 13:17
Show Gist options
  • Save garrettjoecox/8b2a12247e6f2b047d593f7d0b9579f0 to your computer and use it in GitHub Desktop.
Save garrettjoecox/8b2a12247e6f2b047d593f7d0b9579f0 to your computer and use it in GitHub Desktop.
Some documentation changes for zplayer
const fs = require('fs');
const path = require('path');
const C_FILES_REGEX = /.+(\.cpp|\.c|\.inc|\.h)$/;
const variablesMap = {
'D_80125DE8': 'gPlayerLeftHandBgsDLs',
'D_80125E08': 'gPlayerLeftHandOpenDLs',
'D_80125E18': 'gPlayerLeftHandClosedDLs',
'D_80125EF8': 'gPlayerLeftHandBoomerangDLs',
'D_80125CE8': 'sPlayerRightHandShieldDLs',
'D_80125D28': 'sSheathWithSwordDLs',
'D_80125D88': 'sSheathWithoutSwordDLs',
'D_80125E28': 'sPlayerLeftHandSwordDLs2',
'D_80125E38': 'sPlayerLeftHandSwordDLs',
'D_80125E48': 'sPlayerRightHandOpenDLs',
'D_80125E58': 'sPlayerRightHandClosedDLs',
'D_80125E68': 'sPlayerRightHandBowSlingshotDLs',
'D_80125E78': 'sSwordAndSheathDLs',
'D_80125E88': 'sSheathDLs',
'D_80125E98': 'sPlayerWaistDLs',
'D_80125EA8': 'sPlayerRightHandBowSlingshotDLs2',
'D_80125EB8': 'sPlayerRightHandOcarinaDLs',
'D_80125EC8': 'sPlayerRightHandOotDLs',
'D_80125ED8': 'sPlayerRightHandHookshotDLs',
'D_80125EE8': 'sPlayerLeftHandHammerDLs',
'D_80125F08': 'sPlayerLeftHandBottleDLs',
'D_80125F30': 'sFirstPersonForearmDLs',
'D_80160014': 'sLeftHandType',
'D_80160018': 'sRightHandType',
'D_8012602C': 'sZeroVec',
'D_80126128': 'sLeftHandArrowVec3',
'D_80126154': 'sRightHandLimbModelShieldQuadVertices',
'D_8012619C': 'sSheathLimbModelShieldQuadVertices',
'D_801261CC': 'sSheathLimbModelShieldOnBackPos',
'D_801261D8': 'sSheathLimbModelShieldOnBackZyxRot',
'D_801261E0': 'sLeftRightFootLimbModelFootPos',
'D_801261F8': 'sPauseModelGroupBySword',
'sArmOutDLs': 'sFirstPersonLeftForearmDLs',
'sHandOutDLs': 'sFirstPersonLeftHandDLs',
'sRightShoulderNearDLs': 'sFirstPersonRightShoulderDLs',
'sHoldingFirstPersonWeaponDLs': 'sFirstPersonRightHandHoldingWeaponDLs',
'sSwordLengths': 'sMeleeWeaponLengths',
'swordState': 'meleeWeaponState',
'PLAYER_ANIMGROUP_0': 'PLAYER_ANIMGROUP_wait',
'PLAYER_ANIMGROUP_1': 'PLAYER_ANIMGROUP_walk',
'PLAYER_ANIMGROUP_2': 'PLAYER_ANIMGROUP_run',
'PLAYER_ANIMGROUP_3': 'PLAYER_ANIMGROUP_damage_run',
'PLAYER_ANIMGROUP_4': 'PLAYER_ANIMGROUP_heavy_run',
'PLAYER_ANIMGROUP_5': 'PLAYER_ANIMGROUP_waitL',
'PLAYER_ANIMGROUP_6': 'PLAYER_ANIMGROUP_waitR',
'PLAYER_ANIMGROUP_7': 'PLAYER_ANIMGROUP_wait2waitR',
'PLAYER_ANIMGROUP_8': 'PLAYER_ANIMGROUP_normal2fighter',
'PLAYER_ANIMGROUP_9': 'PLAYER_ANIMGROUP_doorA_free',
'PLAYER_ANIMGROUP_10': 'PLAYER_ANIMGROUP_doorA',
'PLAYER_ANIMGROUP_11': 'PLAYER_ANIMGROUP_doorB_free',
'PLAYER_ANIMGROUP_12': 'PLAYER_ANIMGROUP_doorB',
'PLAYER_ANIMGROUP_13': 'PLAYER_ANIMGROUP_carryB',
'PLAYER_ANIMGROUP_14': 'PLAYER_ANIMGROUP_landing',
'PLAYER_ANIMGROUP_15': 'PLAYER_ANIMGROUP_short_landing',
'PLAYER_ANIMGROUP_16': 'PLAYER_ANIMGROUP_landing_roll',
'PLAYER_ANIMGROUP_17': 'PLAYER_ANIMGROUP_hip_down',
'PLAYER_ANIMGROUP_18': 'PLAYER_ANIMGROUP_walk_endL',
'PLAYER_ANIMGROUP_19': 'PLAYER_ANIMGROUP_walk_endR',
'PLAYER_ANIMGROUP_20': 'PLAYER_ANIMGROUP_defense',
'PLAYER_ANIMGROUP_21': 'PLAYER_ANIMGROUP_defense_wait',
'PLAYER_ANIMGROUP_22': 'PLAYER_ANIMGROUP_defense_end',
'PLAYER_ANIMGROUP_23': 'PLAYER_ANIMGROUP_side_walk',
'PLAYER_ANIMGROUP_24': 'PLAYER_ANIMGROUP_side_walkL',
'PLAYER_ANIMGROUP_25': 'PLAYER_ANIMGROUP_side_walkR',
'PLAYER_ANIMGROUP_26': 'PLAYER_ANIMGROUP_45_turn',
'PLAYER_ANIMGROUP_27': 'PLAYER_ANIMGROUP_waitL2wait',
'PLAYER_ANIMGROUP_28': 'PLAYER_ANIMGROUP_waitR2wait',
'PLAYER_ANIMGROUP_29': 'PLAYER_ANIMGROUP_throw',
'PLAYER_ANIMGROUP_30': 'PLAYER_ANIMGROUP_put',
'PLAYER_ANIMGROUP_31': 'PLAYER_ANIMGROUP_back_walk',
'PLAYER_ANIMGROUP_32': 'PLAYER_ANIMGROUP_check',
'PLAYER_ANIMGROUP_33': 'PLAYER_ANIMGROUP_check_wait',
'PLAYER_ANIMGROUP_34': 'PLAYER_ANIMGROUP_check_end',
'PLAYER_ANIMGROUP_35': 'PLAYER_ANIMGROUP_pull_start',
'PLAYER_ANIMGROUP_36': 'PLAYER_ANIMGROUP_pulling',
'PLAYER_ANIMGROUP_37': 'PLAYER_ANIMGROUP_pull_end',
'PLAYER_ANIMGROUP_38': 'PLAYER_ANIMGROUP_fall_up',
'PLAYER_ANIMGROUP_39': 'PLAYER_ANIMGROUP_jump_climb_hold',
'PLAYER_ANIMGROUP_40': 'PLAYER_ANIMGROUP_jump_climb_wait',
'PLAYER_ANIMGROUP_41': 'PLAYER_ANIMGROUP_jump_climb_up',
'PLAYER_ANIMGROUP_42': 'PLAYER_ANIMGROUP_down_slope_slip_end',
'PLAYER_ANIMGROUP_43': 'PLAYER_ANIMGROUP_up_slope_slip_end',
'PLAYER_ANIMGROUP_44': 'PLAYER_ANIMGROUP_nwait',
'PLAYER_IA_STICK': 'PLAYER_IA_DEKU_STICK',
'PLAYER_IA_NUT': 'PLAYER_IA_DEKU_NUT',
'PLAYER_IA_OCARINA_TIME': 'PLAYER_IA_OCARINA_OF_TIME',
'PLAYER_IA_LENS': 'PLAYER_IA_LENS_OF_TRUTH',
'PLAYER_IA_BEAN': 'PLAYER_IA_MAGIC_BEAN',
'PLAYER_IA_BOTTLE_MILK': 'PLAYER_IA_BOTTLE_MILK_FULL',
'PLAYER_IA_BOTTLE_LETTER': 'PLAYER_IA_BOTTLE_RUTOS_LETTER',
'PLAYER_IA_LETTER_ZELDA': 'PLAYER_IA_ZELDAS_LETTER',
'PLAYER_IA_MASK_BUNNY': 'PLAYER_IA_MASK_BUNNY_HOOD',
'PLAYER_IA_SAW': 'PLAYER_IA_POACHERS_SAW',
'PLAYER_IA_SWORD_BROKEN': 'PLAYER_IA_BROKEN_GORONS_SWORD',
'PLAYER_IA_SWORD_BGS': 'PLAYER_IA_SWORD_BIGGORON',
'PLAYER_SWORD_BGS': 'PLAYER_SWORD_BIGGORON',
};
const functionsMap = {
'func_8008F470': 'Player_DrawImpl',
'func_8008FCC8': 'Player_OverrideLimbDrawGameplayCommon',
'func_80090014': 'Player_OverrideLimbDrawGameplayDefault',
'func_800902F0': 'Player_OverrideLimbDrawGameplayFirstPerson',
'func_80090440': 'Player_OverrideLimbDrawGameplayCrawling',
'func_80090D20': 'Player_PostLimbDrawGameplay',
'func_8009214C': 'Player_DrawPause',
'func_80090604': 'Player_UpdateShieldCollider',
'func_80091880': 'Player_OverrideLimbDrawPause',
'func_80091A24': 'Player_DrawPauseImpl',
'func_8002F7DC': 'Player_PlaySfx',
'func_8083264C': 'Player_RequestRumble',
'func_8085002C': 'Player_UpdateBunnyEars',
'func_80832210': 'Player_ZeroSpeedXZ',
'func_8008F2F8': 'Player_GetEnvironmentalHazard',
'Player_ItemToActionParam': 'Player_ItemToItemAction',
'Player_GetSwordHeld': 'Player_GetMeleeWeaponHeld',
'Player_ActionToSword': 'Player_ActionToMeleeWeapon',
};
const maps = [variablesMap, functionsMap];
// Regex patterns to match and replace
function processFile(filePath) {
const content = fs.readFileSync(filePath, 'utf8');
let updatedContent = content;
maps.forEach((map) => {
Object.keys(map).forEach((before) => {
const after = map[before];
const beforeRegex = new RegExp(`\\b${before}\\b`, 'g');
updatedContent = updatedContent.replace(beforeRegex, after);
});
});
fs.writeFileSync(filePath, updatedContent, 'utf8');
}
// Recursive function to process files in a directory
function processFiles(dirPath) {
const files = fs.readdirSync(dirPath);
files.forEach((file) => {
const filePath = path.join(dirPath, file);
const stat = fs.statSync(filePath);
if (stat.isDirectory() && !filePath.match(/\.git$/)) {
processFiles(filePath);
} else if (C_FILES_REGEX.test(file)) {
processFile(filePath);
}
});
}
// Start processing files in the directory
processFiles(__dirname);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment