ViewVC Help
View File | Revision Log | View Changeset | Root Listing
root/Oni2/Daodan/src/Daodan_BSL.c
(Generate patch)

Comparing Daodan/src/Daodan_BSL.c (file contents):
Revision 450 by gumby, Wed Jul 22 06:00:30 2009 UTC vs.
Revision 451 by rossy, Sun Jul 26 12:04:44 2009 UTC

# Line 1 | Line 1
1   #include <stdio.h>
2 + #include <stdbool.h>
3   #include <time.h>
4   #include <ffi.h>
5  
6 + #include "inifile.h"
7 +
8   #include "Daodan_BSL.h"
9   #include "Daodan_Utility.h"
10   #include "Daodan_Patch.h"
# Line 148 | Line 151 | uint16_t ONICALL bsl_powerup(sl_callinfo
151                  returnval = &(Chr[index].Inventory_.hasLSI);
152                  is_lsi = 1;
153          }
154 <        else if(!strcmp(args[1].value_str32,"bossshield"))
155 <        {
156 <                ret->value_int32 = Chr[index].Flags & char_bossshield;
157 <                ret->type = sl_int32;
158 <                if (numargs >=3) {
159 <                        if (Chr[index].Flags & char_bossshield) Chr[index].Flags = Chr[index].Flags & ~char_bossshield;
160 <                        else Chr[index].Flags = Chr[index].Flags | char_bossshield;
161 <                }
162 <                return 0;
163 <        }
154 > //      else if(!strcmp(args[1].value_str32,"bossshield"))
155 > //      {
156 > //              ret->value_int32 = Chr[index].Flags & char_bossshield;
157 > //              ret->type = sl_int32;
158 > //              if (numargs >=3) {
159 > //                      if (Chr[index].Flags & char_bossshield) Chr[index].Flags = Chr[index].Flags & ~char_bossshield;
160 > //                      else Chr[index].Flags = Chr[index].Flags | char_bossshield;
161 > //              }
162 > //              return 0;
163 > //      }
164          else return 1;
165          //todo, add setting
166          
# Line 227 | Line 230 | uint16_t ONICALL bsl_getattacker(sl_call
230          Character* Chr = ONgGameState + 0x1260;
231          ActiveCharacter* Active = (ActiveCharacter*)ONrGetActiveCharacter(&Chr[index]);
232          if ((int)Active == 0) return 1;
233 <        ret->value_int32 = Active->LastDamageSourceCharacter;
233 > //      ret->value_int32 = Active->LastDamageSourceCharacter;
234          ret->type = sl_int32;
235          return 0;
236   }
# Line 385 | Line 388 | uint16_t ONICALL cinematic_start_patch(s
388          return ((sl_func)(OniExe + 0x000f3830))(callinfo, numargs, args, dontuse1, dontuse2, ret);
389   }
390  
391 + bool ini_inbsl = false;
392 + bool SLrIniCallback(char* section, bool newsection, char* name, char* value)
393 + {
394 +        if (newsection && !stricmp(section, "bsl"))
395 +                ini_inbsl = true;
396 +        
397 +        if (ini_inbsl)
398 +        {
399 +                bool isptr = false;
400 +                sl_type bsl_type;
401 +                
402 +                if (value[0] == 'p' && value[1] == 't' && value[2] == 'r' && value[3] == ':')
403 +                {
404 +                        isptr = true;
405 +                        value += 4;
406 +                }
407 +                
408 +                char* type = value;
409 +                
410 +                for (; *type; type++)
411 +                        if (*type == ':')
412 +                        {
413 +                                *type = '\0';
414 +                                type++;
415 +                                break;
416 +                        }
417 +                
418 +                if (!*type)
419 +                        DDrStartupMessage("badly formed bsl definition for \"%s\"", name);
420 +                
421 +                if (!strcmp(type, "int"))
422 +                        bsl_type = sl_int32;
423 +                else if (!strcmp(type, "string"))
424 +                        bsl_type = sl_str32;
425 +                else if (!strcmp(type, "float"))
426 +                        bsl_type = sl_float;
427 +                else if (!strcmp(type, "bool"))
428 +                        bsl_type = sl_bool;
429 +                else
430 +                {
431 +                        DDrStartupMessage("unknown type in bsl definition for \"%s\"", name);
432 +                        return true;
433 +                }
434 +                
435 +                if (isptr)
436 +                {
437 +                        char* bsl_var = malloc(strlen(name) + 1);
438 +                        memcpy(bsl_var, name, strlen(name) + 1);
439 +                        switch (bsl_type)
440 +                        {
441 +                                case sl_int32:
442 +                                        SLrGlobalVariable_Register_Int32(bsl_var, "see daodan.ini", (int32_t*)(uint32_t)inifile_parseint(value, false));
443 +                                        break;
444 +                                case sl_float:
445 +                                        SLrGlobalVariable_Register_Float(bsl_var, "see daodan.ini", (float*)(uint32_t)inifile_parseint(value, false));
446 +                                        break;
447 +                                default:
448 +                                        break;
449 +                        }
450 +                }
451 +                else
452 +                {
453 +                        char* bsl_var = malloc(strlen(name) + 1 + sizeof(int32_t));
454 +                        int32_t* bsl_val = (int32_t*)bsl_var;
455 +                        bsl_var += sizeof(int32_t);
456 +                        memcpy(bsl_var, name, strlen(name) + 1);
457 +                        
458 +                        switch (bsl_type)
459 +                        {
460 +                                case sl_int32:
461 +                                        *bsl_val = inifile_parseint(value, false);
462 +                                        SLrGlobalVariable_Register_Int32(bsl_var, "see daodan.ini", bsl_val);
463 +                                        break;
464 +                                case sl_float:
465 +                                        break;
466 +                                default:
467 +                                        break;
468 +                        }
469 +                }
470 +        }
471 +        return true;
472 + }
473 +
474 + void SLrConfig()
475 + {
476 +        DDrStartupMessage("re-parsing daodan.ini for bsl...");
477 +        inifile_read("daodan.ini", SLrIniCallback);
478 +        DDrStartupMessage("finished parsing");
479 + }
480 +
481   void SLrDaodan_Initalize()
482   {
483 +        SLrConfig();
484 +        
485          SLrScript_Command_Register_ReturnType("int32mul", "Multiplies two numbers", "n1:int n2:int", sl_int32, bsl_int32mul);
486          SLrScript_Command_Register_ReturnType("mul", "Multiplies two numbers", "[int1:int|float1:float] [int2:int|float2:float]", sl_float, bsl_mul);
487          
# Line 410 | Line 505 | void SLrDaodan_Initalize()
505  
506          SLrScript_Command_Register_ReturnType("sprintf", "C-style sprintf.", "format:string arg1 arg2 ...", sl_str32, bsl_sprintf);
507          SLrScript_Command_Register_ReturnType("dprintcolor", "prints to console in color", "text:string [color: r b g] [color: r b g]", sl_void, bsl_dprintcolored);
508 <
414 <
415 <
508 >        
509          SLrScript_Command_Register_ReturnType("d_dprint", "prints to console in color", "text:string [color: r b g] [color: r b g]", sl_void, bsl_dprintcolored);
510   }
511 +
512   void SLrDaodan_Patch()
513   {
514          DDrPatch_Int32(OniExe + 0x000f3755, (int)cinematic_start_patch);
515   }
422

Diff Legend

Removed lines
+ Added lines
< Changed lines (old)
> Changed lines (new)