--- Daodan/src/Patches/BSL.c 2014/04/09 00:10:18 995 +++ Daodan/src/Patches/BSL.c 2021/10/24 02:50:22 1161 @@ -430,10 +430,10 @@ uint16_t ONICALL bsl_nametoindex(sl_call typedef struct { char Name[16]; -int Bit; +uint64_t Bit; } KeyBit; -KeyBit Actions1[32] = { +static KeyBit Actions[] = { {"Escape", Action_Escape}, {"Console", Action_Console}, {"PauseScreen", Action_PauseScreen}, @@ -444,17 +444,12 @@ KeyBit Actions1[32] = { {"F6", Action_F6 }, {"F7", Action_F7 }, {"F8", Action_F8 }, - {"StartRecord", Action_StartRecord }, - {"StopRecord", Action_StopRecord }, - {"PlayRecord", Action_PlayRecord }, + {"StartRecord", Action_StartRecord }, + {"StopRecord", Action_StopRecord }, + {"PlayRecord", Action_PlayRecord }, {"F12", Action_F12 }, - {"Unknown1", Action_Unknown1 }, {"LookMode", Action_LookMode }, - {"Screenshot", Action_Screenshot }, - {"Unknown2", Action_Unknown2 }, - {"Unknown3", Action_Unknown3 }, - {"Unknown4", Action_Unknown4 }, - {"Unknown5", Action_Unknown5 }, + {"Screenshot", Action_Screenshot }, {"Forward", Action_Forward }, {"Backward", Action_Backward }, {"TurnLeft", Action_TurnLeft }, @@ -465,27 +460,24 @@ KeyBit Actions1[32] = { {"Crouch", Action_Crouch }, {"Punch",Action_Punch }, {"Kick", Action_Kick }, - {"Block", Action_Block } + {"Block", Action_Block }, + {"Walk", Action_Walk}, + {"Action", Action_Action}, + {"Hypo", Action_Hypo}, + {"Reload", Action_Reload }, + {"Swap", Action_Swap }, + {"Drop", Action_Drop }, + {"Fire1", Action_Fire1 }, + {"Fire2", Action_Fire2 }, + {"Fire3", Action_Fire3 } }; -KeyBit Actions2[9] = { - {"Walk", Action2_Walk}, - {"Action", Action2_Action}, - {"Hypo", Action2_Hypo}, - {"Reload", Action2_Reload }, - {"Swap", Action2_Swap }, - {"Drop", Action2_Drop }, - {"Fire1", Action2_Fire1 }, - {"Fire2", Action2_Fire2 }, - {"Fire3", Action2_Fire3 } -}; uint16_t ONICALL bsl_holdkey(sl_callinfo* callinfo, uint32_t numargs, sl_arg args[], int* dontuse1, int* dontuse2, sl_arg* ret) { uint32_t index; uint32_t i = 2; uint32_t j = 0; - int Input1 = 0; - int Input2 = 0; + uint64_t Input = 0; Character* Chr; ActiveCharacter* Active; if (args[0].type == sl_str32) index = DDrGetCharacterIndexFromName(args[0].val.value_str32); @@ -497,19 +489,13 @@ uint16_t ONICALL bsl_holdkey(sl_callinfo for(i = 1; i < numargs - 1; i++) { for(j = 0; j < 32; j++) { - if(!strcmp(args[i].val.value_str32, Actions1[j].Name)) { - Input1 = Input1 | Actions1[j].Bit; - } - } - for(j = 0; j < 9; j++) { - if(!strcmp(args[i].val.value_str32, Actions2[j].Name)) { - Input2 = Input2 | Actions2[j].Bit; + if(!strcmp(args[i].val.value_str32, Actions[j].Name)) { + Input = Input | Actions[j].Bit; } } } - Active->Input.Current.Actions1 = Active->Input.Current.Actions1 | Input1; - Active->Input.Current.Actions2 = Active->Input.Current.Actions2 | Input2; - if( Input1 + Input2 == 0 ) { + Active->Input.ActionsDown = Active->Input.ActionsDown | Input; + if( Input == 0 ) { DDrConsole_PrintF("Func \"%s\", File \"%s\", Line %d: semantic error, \"%s\": No valid keys given.", callinfo->name, callinfo->calllocation, callinfo->linenumber, callinfo->name); return 0; } @@ -536,26 +522,21 @@ uint16_t ONICALL bsl_isheld(sl_callinfo* // if ((int)Active == 0) return 1; uint32_t i = 2; uint32_t j = 0; - int Input1 = 0; - int Input2 = 0; + uint64_t Input = 0; for(i = 0; i < numargs; i++) { for(j = 0; j < 32; j++) { //DDrConsole_PrintF("Testing %s against %s 0x%x", args[i].val.value_str32, Actions1[j].Name, Actions1[j].Bit); - if(!strcmp(args[i].val.value_str32, Actions1[j].Name)) { - Input1 = Input1 | Actions1[j].Bit; + if(!strcmp(args[i].val.value_str32, Actions[j].Name)) { + Input = Input | Actions[j].Bit; //DDrConsole_PrintF("Success!"); } - - } - for(j = 0; j < 9; j++) { - if(!strcmp(args[i].val.value_str32, Actions2[j].Name)) Input2 = Input2 | Actions2[j].Bit; - + } } //DDrConsole_PrintF("Testing: 0x%x Input: 0x%x",Input1, *(int*)(ONgGameState + 0xB8 + 0x10)); ret->val.value_int32 = 0; ret->type = sl_int32; - if ( (ONgGameState->Input.Current.Actions1 == Input1) && (ONgGameState->Input.Current.Actions2 == Input2)) ret->val.value_int32 = 1; + if (ONgGameState->Input.ActionsDown == Input) ret->val.value_int32 = 1; return 0; } @@ -572,8 +553,7 @@ uint16_t ONICALL bsl_waitforkey(sl_calli int i = 2; int j = 0; - int Input1 = 0; - int Input2 = 0; + uint64_t Input = 0; /* numargs = 0; for(i = 0; args[i].type <= sl_void; i++) @@ -588,22 +568,15 @@ uint16_t ONICALL bsl_waitforkey(sl_calli i = 0; for(j = 0; j < 32; j++) { //DDrConsole_PrintF("Testing %s against %s 0x%x", args[i].val.value_str32, Actions1[j].Name, Actions1[j].Bit); - if(!strcmp(args[i].val.value_str32, Actions1[j].Name)) { - Input1 = Input1 | Actions1[j].Bit; + if(!strcmp(args[i].val.value_str32, Actions[j].Name)) { + Input = Input | Actions[j].Bit; //DDrConsole_PrintF("Success!"); } - - } - for(j = 0; j < 9; j++) { - if(!strcmp(args[i].val.value_str32, Actions2[j].Name)) Input2 = Input2 | Actions2[j].Bit; - + } // } DDrConsole_PrintF("Waiting..."); - if ( - (( ONgGameState->Input.Current.Actions1 & Input1) == Input1) && - (( ONgGameState->Input.Current.Actions2 & Input2) == Input2) - ) + if (( ONgGameState->Input.ActionsDown & Input) == Input) { DDrConsole_PrintF("Found key!"); }