552 |
|
// Character* Chr = ONgGameState->CharacterStorage; |
553 |
|
// ActiveCharacter* Active = (ActiveCharacter*)ONrGetActiveCharacter(&Chr[index]); |
554 |
|
// if ((int)Active == 0) return 1; |
555 |
+ |
|
556 |
|
int i = 2; |
557 |
|
int j = 0; |
558 |
|
int Input1 = 0; |
559 |
|
int Input2 = 0; |
560 |
< |
for(i = 0; i < numargs; i++) { |
560 |
> |
/* |
561 |
> |
numargs = 0; |
562 |
> |
for(i = 0; args[i].type <= sl_void; i++) |
563 |
> |
{ |
564 |
> |
//DDrConsole_PrintF("%i", args[i].type ); |
565 |
> |
numargs++; |
566 |
> |
|
567 |
> |
} |
568 |
> |
if(numargs < 1 || args[0].value == 0) return; |
569 |
> |
//for(i = 0; i < numargs; i++) { |
570 |
> |
*/ |
571 |
> |
i = 0; |
572 |
|
for(j = 0; j < 32; j++) { |
573 |
|
//DDrConsole_PrintF("Testing %s against %s 0x%x", args[i].value_str32, Actions1[j].Name, Actions1[j].Bit); |
574 |
|
if(!strcmp(args[i].value_str32, Actions1[j].Name)) { |
581 |
|
if(!strcmp(args[i].value_str32, Actions2[j].Name)) Input2 = Input2 | Actions2[j].Bit; |
582 |
|
|
583 |
|
} |
584 |
< |
} |
585 |
< |
//DDrConsole_PrintF("Waiting..."); |
584 |
> |
// } |
585 |
> |
DDrConsole_PrintF("Waiting..."); |
586 |
|
if ( |
587 |
|
(( ONgGameState->Input.Current.Actions1 & Input1) == Input1) && |
588 |
|
(( ONgGameState->Input.Current.Actions2 & Input2) == Input2) |
589 |
< |
){ |
589 |
> |
) |
590 |
> |
{ |
591 |
> |
DDrConsole_PrintF("Found key!"); |
592 |
|
} |
593 |
|
else { |
594 |
|
//else (int)*ret = 1; |
595 |
|
*dontuse2 = 1; |
596 |
|
*dontuse1 = 1; |
597 |
|
} |
598 |
< |
/* |
585 |
< |
__asm__( |
586 |
< |
"movl 0x10(%esp), %edx\n\t" |
587 |
< |
"movl $1,(%eax)\n\t" |
588 |
< |
); |
589 |
< |
//ret->type = sl_void |
590 |
< |
*/ return 0; |
598 |
> |
return 0; |
599 |
|
} |
600 |
|
|
601 |
< |
/* |
601 |
> |
|
602 |
|
uint16_t ONICALL bsl_sprintf(sl_callinfo* callinfo, uint32_t numargs, sl_arg args[], int* dontuse1, int* dontuse2, sl_arg* ret) |
603 |
|
{ |
604 |
< |
if (numargs < 2) |
604 |
> |
char output[1024]; |
605 |
> |
char buffer[1024]; |
606 |
> |
int i; |
607 |
> |
char* placeinoutput = output; |
608 |
> |
char* placeininput = args[0].value_str32; |
609 |
> |
int formatnum = 0; |
610 |
> |
//fix the broken bsl numargs... |
611 |
> |
numargs = 0; |
612 |
> |
|
613 |
> |
for(i = 0; args[i].type < sl_void; i++) |
614 |
> |
{ |
615 |
> |
numargs++; |
616 |
> |
} |
617 |
> |
|
618 |
> |
|
619 |
> |
if (numargs < 1) |
620 |
|
return 1; |
621 |
|
|
622 |
< |
char output[255]; |
623 |
< |
int i; |
622 |
> |
while(1) |
623 |
> |
{ |
624 |
> |
int size; |
625 |
> |
//s is the pointer to the args |
626 |
> |
char* s = strchr(placeininput , '%'); |
627 |
> |
//we didnt find a %, break! |
628 |
> |
if(!s) |
629 |
> |
{ |
630 |
> |
strcpy(placeinoutput, placeininput); |
631 |
> |
break; |
632 |
> |
} |
633 |
> |
size = (int)s - (int)placeininput ; |
634 |
> |
//we found one, so copy the portion of string |
635 |
> |
|
636 |
> |
|
637 |
> |
|
638 |
> |
memcpy( placeinoutput,placeininput, size); |
639 |
> |
placeininput += size; |
640 |
> |
placeinoutput += size; |
641 |
> |
|
642 |
> |
memset( placeinoutput, '%', (int)pow(2, formatnum)); |
643 |
> |
placeinoutput += (int)pow(2, formatnum); |
644 |
> |
|
645 |
> |
|
646 |
> |
placeininput += 1; |
647 |
> |
*placeinoutput = 0; |
648 |
> |
formatnum++; |
649 |
> |
|
650 |
> |
} |
651 |
> |
//strcpy( output, args[0].value_str32 ); |
652 |
> |
|
653 |
|
for(i = 1; i < numargs; i++) { |
654 |
< |
sprintf(output, args[0].value_str32, args[i].value_str32); |
654 |
> |
//sprintf(output, output, args[i].value_str32); |
655 |
> |
memcpy(buffer, output, 1024); |
656 |
> |
if(args[i].value == 0) break; |
657 |
> |
switch(args[i].type) |
658 |
> |
{ |
659 |
> |
case sl_bool: |
660 |
> |
case sl_int32: |
661 |
> |
sprintf(output, buffer, args[i].value_int32); |
662 |
> |
break; |
663 |
> |
case sl_float: |
664 |
> |
//crashes oni, why? |
665 |
> |
// sprintf(output, output, args[i].value_float); |
666 |
> |
break; |
667 |
> |
case sl_str32: |
668 |
> |
sprintf(output, buffer, args[i].value_str32); |
669 |
> |
break; |
670 |
> |
case sl_void: |
671 |
> |
default: |
672 |
> |
break; |
673 |
> |
} |
674 |
|
} |
675 |
< |
|
675 |
> |
//output[32] = 0; |
676 |
|
ret->value_str32 = output; |
677 |
|
ret->type = sl_str32; |
678 |
|
return 0; |
679 |
|
} |
680 |
< |
*/ |
680 |
> |
|
681 |
> |
//Sorry rossy, I broke this. FFI isnt in windows |
682 |
|
/* |
683 |
|
uint16_t ONICALL bsl_sprintf(sl_callinfo* callinfo, uint32_t numargs, sl_arg args[], int* dontuse1, int* dontuse2, sl_arg* ret) |
684 |
|
{ |
685 |
+ |
|
686 |
+ |
|
687 |
+ |
int ffi_ret; |
688 |
+ |
char* str = NULL; |
689 |
+ |
int size = 0; |
690 |
+ |
|
691 |
+ |
ffi_cif cif; |
692 |
+ |
ffi_type* ffi_args[256]; |
693 |
+ |
void* values[256]; |
694 |
+ |
int i; |
695 |
+ |
numargs = 0; |
696 |
+ |
for(i = 0; args[i].type <= sl_void; i++) |
697 |
+ |
{ |
698 |
+ |
//DDrConsole_PrintF("%i", args[i].type ); |
699 |
+ |
numargs++; |
700 |
+ |
|
701 |
+ |
} |
702 |
+ |
|
703 |
|
if (numargs < 1 || args[0].type != sl_str32) |
704 |
|
{ |
705 |
|
DDrConsole_PrintF("Func \"%s\", File \"%s\", Line %d: semantic error, \"%s\": parameter list does not match: format:string arg1 arg2 ...", callinfo->name, callinfo->calllocation, callinfo->linenumber, callinfo->name); |
709 |
|
if (!args[0].value_str32) |
710 |
|
args[0].value_str32 = ""; |
711 |
|
|
622 |
– |
int ffi_ret; |
623 |
– |
char* str = NULL; |
624 |
– |
int size = 0; |
712 |
|
|
626 |
– |
ffi_cif cif; |
627 |
– |
ffi_type* ffi_args[256]; |
628 |
– |
void* values[256]; |
713 |
|
|
714 |
|
ffi_args[0] = &ffi_type_pointer; |
715 |
|
values[0] = &str; |
716 |
|
ffi_args[1] = &ffi_type_uint32; |
717 |
|
values[1] = &size; |
718 |
|
|
719 |
< |
int i; |
719 |
> |
|
720 |
|
for(i = 2; i < numargs + 2; i ++) |
721 |
|
{ |
722 |
|
if (args[i - 2].type == sl_float) |
737 |
|
|
738 |
|
if (ffi_prep_cif(&cif, FFI_DEFAULT_ABI, i, &ffi_type_sint32, ffi_args) != FFI_OK) |
739 |
|
return 1; |
740 |
< |
ffi_call(&cif, (void*)snprintf, (void*)&ffi_ret, values); |
740 |
> |
ffi_call(&cif, (void*)_snprintf, (void*)&ffi_ret, values); |
741 |
|
str = malloc(ffi_ret + 1); |
742 |
|
size = ffi_ret + 1; |
743 |
< |
ffi_call(&cif, (void*)snprintf, (void*)&ffi_ret, values); |
743 |
> |
ffi_call(&cif, (void*)_snprintf, (void*)&ffi_ret, values); |
744 |
|
ret->value_str32 = str; |
745 |
|
ret->type = sl_str32; |
746 |
|
return 0; |
860 |
|
{ |
861 |
|
void* TSFFTahoma; |
862 |
|
int returnval; |
779 |
– |
|
863 |
|
TMrInstance_GetDataPtr( 'TSFF', "Tahoma", &TSFFTahoma); |
864 |
|
returnval = TSrContext_New( TSFFTahoma, 7, 1, 1, 0, &TSrTest); |
865 |
|
return 0; |
867 |
|
|
868 |
|
void SLrDaodan_Initalize() |
869 |
|
{ |
787 |
– |
//Calculating the value of the needed offset is much more reliable when the compiler does it for you. |
788 |
– |
|
789 |
– |
//TODO: fix moonshadow. |
790 |
– |
Character * Chr = 0; |
791 |
– |
|
792 |
– |
int NoPath = (int)&(Chr[0].RegenHax) & 0x000000FF; |
793 |
– |
|
794 |
– |
|
795 |
– |
|
796 |
– |
const char regen_patch[] = |
797 |
– |
{0x90, 0x90, 0x90, 0x90, 0x90, // mov al, _WPgRegenerationCheat |
798 |
– |
0x90, 0x90, // test al, al |
799 |
– |
0x90, 0x90, // jz short loc_51BB98 |
800 |
– |
0x8B, 0x86, (char)NoPath, 0x01}; |
801 |
– |
DDrPatch_Const(OniExe + 0x0011BB64, regen_patch); |
802 |
– |
|
870 |
|
SLrConfig(); |
871 |
|
|
872 |
|
SLrScript_Command_Register_Void("debug_daodan","Adds text to screen", "", new_text); |
890 |
|
SLrScript_Command_Register_ReturnType("d_isheld","Checks if player is holding a key", "[ai_name:string | script_id:int] [keys:string]", sl_int32, bsl_isheld); |
891 |
|
SLrScript_Command_Register_ReturnType("d_location","Returns the X, Y or Z coord of a character", "ai_name:string | script_id:int xyz:string [newlocation:float]", sl_float, bsl_location); |
892 |
|
SLrScript_Command_Register_ReturnType("d_distance","Returns the distance between two characters", "ai_name:string | script_id:int ai_name:string | script_id:int", sl_float, bsl_distance); |
893 |
< |
SLrScript_Command_Register_Void("d_waitforkey","Waits for a keypress from the player", "keys", bsl_waitforkey); |
893 |
> |
SLrScript_Command_Register_Void("d_waitforkey","Waits for a keypress from the player", "key:string", bsl_waitforkey); |
894 |
|
|
895 |
|
//broken, only works for one damage type. |
896 |
|
//SLrDaodan_Register_ReturnType("d_getattacker","Gets the last person to hurt a character", "[ai_name:string | script_id:int]", sl_int32, bsl_getattacker); |
898 |
|
//used for debugging. |
899 |
|
// SLrDaodan_Register_ReturnType("d_active","Returns a hex offset. ;)", "[ai_name:string | script_id:int]", sl_int32, bsl_getactiveoffset); |
900 |
|
|
901 |
< |
//SLrDaodan_Register_ReturnType("sprintf", "C-style sprintf.", "format:string arg1 arg2 ...", sl_str32, bsl_sprintf); |
835 |
< |
|
901 |
> |
SLrScript_Command_Register_Void("sprintf", "C-style sprintf.", "", bsl_sprintf); |
902 |
|
SLrScript_Command_Register_ReturnType("st", "prints to console in color", "text:string color1:int color2:int", sl_void, bsl_dprintcolored); |
903 |
|
|
904 |
|
//Flatline |