codemp/game/bg_saberLoad.c File Reference

#include "q_shared.h"
#include "bg_public.h"
#include "bg_local.h"
#include "w_saber.h"
#include "../namespace_begin.h"
#include "../namespace_end.h"

Go to the source code of this file.

Defines

#define MAX_SABER_DATA_SIZE   0x80000
#define DEFAULT_SABER   "Kyle"

Functions

int trap_FS_FOpenFile (const char *qpath, fileHandle_t *f, fsMode_t mode)
void trap_FS_Read (void *buffer, int len, fileHandle_t f)
void trap_FS_Write (const void *buffer, int len, fileHandle_t f)
void trap_FS_FCloseFile (fileHandle_t f)
int trap_FS_GetFileList (const char *path, const char *extension, char *listbuf, int bufsize)
qhandle_t trap_R_RegisterSkin (const char *name)
int BG_SoundIndex (char *sound)
qboolean BG_ParseLiteral (const char **data, const char *string)
saber_colors_t TranslateSaberColor (const char *name)
saber_styles_t TranslateSaberStyle (const char *name)
qboolean WP_SaberBladeUseSecondBladeStyle (saberInfo_t *saber, int bladeNum)
qboolean WP_SaberBladeDoTransitionDamage (saberInfo_t *saber, int bladeNum)
qboolean WP_UseFirstValidSaberStyle (saberInfo_t *saber1, saberInfo_t *saber2, int saberHolstered, int *saberAnimLevel)
qboolean WP_SaberStyleValidForSaber (saberInfo_t *saber1, saberInfo_t *saber2, int saberHolstered, int saberAnimLevel)
qboolean WP_SaberCanTurnOffSomeBlades (saberInfo_t *saber)
void WP_SaberSetDefaults (saberInfo_t *saber)
qboolean WP_SaberParseParms (const char *SaberName, saberInfo_t *saber)
qboolean WP_SaberParseParm (const char *saberName, const char *parmname, char *saberData)
qboolean WP_SaberValidForPlayerInMP (const char *saberName)
void WP_RemoveSaber (saberInfo_t *sabers, int saberNum)
void WP_SetSaber (int entNum, saberInfo_t *sabers, int saberNum, const char *saberName)
void WP_SaberSetColor (saberInfo_t *sabers, int saberNum, int bladeNum, char *colorName)
void WP_SaberLoadParms (void)
void BG_BLADE_ActivateTrail (bladeInfo_t *blade, float duration)
void BG_BLADE_DeactivateTrail (bladeInfo_t *blade, float duration)
void BG_SI_Activate (saberInfo_t *saber)
void BG_SI_Deactivate (saberInfo_t *saber)
void BG_SI_BladeActivate (saberInfo_t *saber, int iBlade, qboolean bActive)
qboolean BG_SI_Active (saberInfo_t *saber)
void BG_SI_SetLength (saberInfo_t *saber, float length)
void BG_SI_SetDesiredLength (saberInfo_t *saber, float len, int bladeNum)
void BG_SI_SetLengthGradual (saberInfo_t *saber, int time)
float BG_SI_Length (saberInfo_t *saber)
float BG_SI_LengthMax (saberInfo_t *saber)
void BG_SI_ActivateTrail (saberInfo_t *saber, float duration)
void BG_SI_DeactivateTrail (saberInfo_t *saber, float duration)

Variables

stringID_table_t animTable [MAX_ANIMATIONS+1]
stringID_table_t FPTable []
stringID_table_t SaberTable []
stringID_table_t SaberMoveTable []


Define Documentation

#define DEFAULT_SABER   "Kyle"
 

Definition at line 615 of file bg_saberLoad.c.

Referenced by WP_SaberParseParms().

#define MAX_SABER_DATA_SIZE   0x80000
 

Definition at line 43 of file bg_saberLoad.c.

Referenced by UI_SaberLoadParms(), and WP_SaberLoadParms().


Function Documentation

void BG_BLADE_ActivateTrail bladeInfo_t blade,
float  duration
 

Definition at line 2803 of file bg_saberLoad.c.

References saberTrail_t::duration, saberTrail_t::inAction, qtrue, and bladeInfo_t::trail.

Referenced by BG_SI_ActivateTrail().

02804 {
02805         blade->trail.inAction = qtrue;
02806         blade->trail.duration = duration;
02807 }

void BG_BLADE_DeactivateTrail bladeInfo_t blade,
float  duration
 

Definition at line 2809 of file bg_saberLoad.c.

References saberTrail_t::duration, saberTrail_t::inAction, qfalse, and bladeInfo_t::trail.

Referenced by BG_SI_DeactivateTrail().

02810 {
02811         blade->trail.inAction = qfalse;
02812         blade->trail.duration = duration;
02813 }

qboolean BG_ParseLiteral const char **  data,
const char *  string
 

Definition at line 129 of file bg_saberLoad.c.

References COM_ParseExt(), Com_Printf(), Q_stricmp(), qboolean, qfalse, and qtrue.

Referenced by NPC_ParseParms(), NPC_Precache(), NPC_PrecacheAnimationCFG(), WP_SaberParseParm(), and WP_SaberParseParms().

00130 {
00131         const char      *token;
00132 
00133         token = COM_ParseExt( data, qtrue );
00134         if ( token[0] == 0 ) 
00135         {
00136                 Com_Printf( "unexpected EOF\n" );
00137                 return qtrue;
00138         }
00139 
00140         if ( Q_stricmp( token, string ) ) 
00141         {
00142                 Com_Printf( "required string '%s' missing\n", string );
00143                 return qtrue;
00144         }
00145 
00146         return qfalse;
00147 }

void BG_SI_Activate saberInfo_t saber  ) 
 

Definition at line 2815 of file bg_saberLoad.c.

References bladeInfo_t::active, saberInfo_t::blade, saberInfo_t::numBlades, and qtrue.

02816 {
02817         int i;
02818 
02819         for ( i = 0; i < saber->numBlades; i++ )
02820         {
02821                 saber->blade[i].active = qtrue;
02822         }
02823 }

void BG_SI_ActivateTrail saberInfo_t saber,
float  duration
 

Definition at line 2989 of file bg_saberLoad.c.

References BG_BLADE_ActivateTrail(), saberInfo_t::blade, and saberInfo_t::numBlades.

02990 {
02991         int i;
02992 
02993         for ( i = 0; i < saber->numBlades; i++ )
02994         {
02995                 //saber->blade[i].ActivateTrail( duration );
02996                 BG_BLADE_ActivateTrail(&saber->blade[i], duration);
02997         }
02998 }

qboolean BG_SI_Active saberInfo_t saber  ) 
 

Definition at line 2849 of file bg_saberLoad.c.

References bladeInfo_t::active, saberInfo_t::blade, saberInfo_t::numBlades, qboolean, qfalse, and qtrue.

02850 {
02851         int i;
02852 
02853         for ( i = 0; i < saber->numBlades; i++ )
02854         {
02855                 if ( saber->blade[i].active )
02856                 {
02857                         return qtrue;
02858                 }
02859         }
02860         return qfalse;
02861 }

void BG_SI_BladeActivate saberInfo_t saber,
int  iBlade,
qboolean  bActive
 

Definition at line 2840 of file bg_saberLoad.c.

References bladeInfo_t::active, saberInfo_t::blade, and saberInfo_t::numBlades.

02841 {
02842         // Validate blade ID/Index.
02843         if ( iBlade < 0 || iBlade >= saber->numBlades )
02844                 return;
02845 
02846         saber->blade[iBlade].active = bActive;
02847 }

void BG_SI_Deactivate saberInfo_t saber  ) 
 

Definition at line 2825 of file bg_saberLoad.c.

References bladeInfo_t::active, saberInfo_t::blade, saberInfo_t::numBlades, and qfalse.

Referenced by WP_RemoveSaber().

02826 {
02827         int i;
02828 
02829         for ( i = 0; i < saber->numBlades; i++ )
02830         {
02831                 saber->blade[i].active = qfalse;
02832         }
02833 }

void BG_SI_DeactivateTrail saberInfo_t saber,
float  duration
 

Definition at line 3000 of file bg_saberLoad.c.

References BG_BLADE_DeactivateTrail(), saberInfo_t::blade, and saberInfo_t::numBlades.

03001 {
03002         int i;
03003 
03004         for ( i = 0; i < saber->numBlades; i++ )
03005         {
03006                 //saber->blade[i].DeactivateTrail( duration );
03007                 BG_BLADE_DeactivateTrail(&saber->blade[i], duration);
03008         }
03009 }

float BG_SI_Length saberInfo_t saber  ) 
 

Definition at line 2959 of file bg_saberLoad.c.

References saberInfo_t::blade, bladeInfo_t::length, and saberInfo_t::numBlades.

02960 {//return largest length
02961         int len1 = 0;
02962         int i;
02963 
02964         for ( i = 0; i < saber->numBlades; i++ )
02965         {
02966                 if ( saber->blade[i].length > len1 )
02967                 {
02968                         len1 = saber->blade[i].length; 
02969                 }
02970         }
02971         return len1;
02972 }

float BG_SI_LengthMax saberInfo_t saber  ) 
 

Definition at line 2974 of file bg_saberLoad.c.

References saberInfo_t::blade, bladeInfo_t::lengthMax, and saberInfo_t::numBlades.

02975 { 
02976         int len1 = 0;
02977         int i;
02978 
02979         for ( i = 0; i < saber->numBlades; i++ )
02980         {
02981                 if ( saber->blade[i].lengthMax > len1 )
02982                 {
02983                         len1 = saber->blade[i].lengthMax; 
02984                 }
02985         }
02986         return len1;
02987 }

void BG_SI_SetDesiredLength saberInfo_t saber,
float  len,
int  bladeNum
 

Definition at line 2874 of file bg_saberLoad.c.

References saberInfo_t::blade, bladeInfo_t::desiredLength, and saberInfo_t::numBlades.

Referenced by CG_CheckPlayerG2Weapons(), CG_NewClientInfo(), CG_Player(), and CG_ResetPlayerEntity().

02875 {
02876         int i, startBlade = 0, maxBlades = saber->numBlades;
02877 
02878         if ( bladeNum >= 0 && bladeNum < saber->numBlades)
02879         {//doing this on a specific blade
02880                 startBlade = bladeNum;
02881                 maxBlades = bladeNum+1;
02882         }
02883         for (i = startBlade; i < maxBlades; i++)
02884         {
02885                 saber->blade[i].desiredLength = len;
02886         }
02887 }

void BG_SI_SetLength saberInfo_t saber,
float  length
 

Definition at line 2863 of file bg_saberLoad.c.

References saberInfo_t::blade, bladeInfo_t::length, and saberInfo_t::numBlades.

Referenced by CG_Player(), and WP_RemoveSaber().

02864 {
02865         int i;
02866 
02867         for ( i = 0; i < saber->numBlades; i++ )
02868         {
02869                 saber->blade[i].length = length;
02870         }
02871 }

void BG_SI_SetLengthGradual saberInfo_t saber,
int  time
 

Definition at line 2890 of file bg_saberLoad.c.

References saberInfo_t::blade, bladeInfo_t::desiredLength, bladeInfo_t::extendDebounce, bladeInfo_t::length, bladeInfo_t::lengthMax, and saberInfo_t::numBlades.

Referenced by CG_Player().

02891 {
02892         int i;
02893         float amt, dLen;
02894 
02895         for (i = 0; i < saber->numBlades; i++)
02896         {
02897                 dLen = saber->blade[i].desiredLength;
02898 
02899                 if (dLen == -1)
02900                 { //assume we want max blade len
02901                         dLen = saber->blade[i].lengthMax;
02902                 }
02903 
02904                 if (saber->blade[i].length == dLen)
02905                 {
02906                         continue;
02907                 }
02908 
02909                 if (saber->blade[i].length == saber->blade[i].lengthMax ||
02910                         saber->blade[i].length == 0)
02911                 {
02912                         saber->blade[i].extendDebounce = time;
02913                         if (saber->blade[i].length == 0)
02914                         {
02915                                 saber->blade[i].length++;
02916                         }
02917                         else
02918                         {
02919                                 saber->blade[i].length--;
02920                         }
02921                 }
02922 
02923                 amt = (time - saber->blade[i].extendDebounce)*0.01;
02924 
02925                 if (amt < 0.2f)
02926                 {
02927                         amt = 0.2f;
02928                 }
02929 
02930                 if (saber->blade[i].length < dLen)
02931                 {
02932                         saber->blade[i].length += amt;
02933 
02934                         if (saber->blade[i].length > dLen)
02935                         {
02936                                 saber->blade[i].length = dLen;
02937                         }
02938                         if (saber->blade[i].length > saber->blade[i].lengthMax)
02939                         {
02940                                 saber->blade[i].length = saber->blade[i].lengthMax;
02941                         }
02942                 }
02943                 else if (saber->blade[i].length > dLen)
02944                 {
02945                         saber->blade[i].length -= amt;
02946 
02947                         if (saber->blade[i].length < dLen)
02948                         {
02949                                 saber->blade[i].length = dLen;
02950                         }
02951                         if (saber->blade[i].length < 0)
02952                         {
02953                                 saber->blade[i].length = 0;
02954                         }
02955                 }
02956         }
02957 }

int BG_SoundIndex char *  sound  ) 
 

Definition at line 32 of file bg_saberLoad.c.

References G_SoundIndex(), and trap_S_RegisterSound().

Referenced by WP_SaberParseParms(), and WP_SaberSetDefaults().

00033 {
00034 #ifdef QAGAME
00035         return G_SoundIndex(sound);
00036 #elif defined CGAME
00037         return trap_S_RegisterSound(sound);
00038 #endif
00039 }

saber_colors_t TranslateSaberColor const char *  name  ) 
 

Definition at line 149 of file bg_saberLoad.c.

00150 {
00151         if ( !Q_stricmp( name, "red" ) ) 
00152         {
00153                 return SABER_RED;
00154         }
00155         if ( !Q_stricmp( name, "orange" ) ) 
00156         {
00157                 return SABER_ORANGE;
00158         }
00159         if ( !Q_stricmp( name, "yellow" ) ) 
00160         {
00161                 return SABER_YELLOW;
00162         }
00163         if ( !Q_stricmp( name, "green" ) ) 
00164         {
00165                 return SABER_GREEN;
00166         }
00167         if ( !Q_stricmp( name, "blue" ) ) 
00168         {
00169                 return SABER_BLUE;
00170         }
00171         if ( !Q_stricmp( name, "purple" ) ) 
00172         {
00173                 return SABER_PURPLE;
00174         }
00175         if ( !Q_stricmp( name, "random" ) ) 
00176         {
00177                 return ((saber_colors_t)(Q_irand( SABER_ORANGE, SABER_PURPLE )));
00178         }
00179         return SABER_BLUE;
00180 }

saber_styles_t TranslateSaberStyle const char *  name  ) 
 

Definition at line 182 of file bg_saberLoad.c.

References name, Q_stricmp(), saber_styles_t, SS_DESANN, SS_DUAL, SS_FAST, SS_MEDIUM, SS_NONE, SS_STAFF, SS_STRONG, and SS_TAVION.

Referenced by WP_SaberParseParms().

00183 {
00184         if ( !Q_stricmp( name, "fast" ) ) 
00185         {
00186                 return SS_FAST;
00187         }
00188         if ( !Q_stricmp( name, "medium" ) ) 
00189         {
00190                 return SS_MEDIUM;
00191         }
00192         if ( !Q_stricmp( name, "strong" ) ) 
00193         {
00194                 return SS_STRONG;
00195         }
00196         if ( !Q_stricmp( name, "desann" ) ) 
00197         {
00198                 return SS_DESANN;
00199         }
00200         if ( !Q_stricmp( name, "tavion" ) ) 
00201         {
00202                 return SS_TAVION;
00203         }
00204         if ( !Q_stricmp( name, "dual" ) ) 
00205         {
00206                 return SS_DUAL;
00207         }
00208         if ( !Q_stricmp( name, "staff" ) ) 
00209         {
00210                 return SS_STAFF;
00211         }
00212         return SS_NONE;
00213 }

void trap_FS_FCloseFile fileHandle_t  f  ) 
 

Definition at line 95 of file cg_syscalls.c.

00095                                              {
00096         syscall( CG_FS_FCLOSEFILE, f );
00097 }

int trap_FS_FOpenFile const char *  qpath,
fileHandle_t f,
fsMode_t  mode
 

Definition at line 83 of file cg_syscalls.c.

00083                                                                                        {
00084         return syscall( CG_FS_FOPENFILE, qpath, f, mode );
00085 }

int trap_FS_GetFileList const char *  path,
const char *  extension,
char *  listbuf,
int  bufsize
 

Definition at line 99 of file cg_syscalls.c.

00099                                                                                                 {
00100         return syscall( CG_FS_GETFILELIST, path, extension, listbuf, bufsize );
00101 }

void trap_FS_Read void *  buffer,
int  len,
fileHandle_t  f
 

Definition at line 87 of file cg_syscalls.c.

00087                                                               {
00088         syscall( CG_FS_READ, buffer, len, f );
00089 }

void trap_FS_Write const void *  buffer,
int  len,
fileHandle_t  f
 

Definition at line 91 of file cg_syscalls.c.

00091                                                                      {
00092         syscall( CG_FS_WRITE, buffer, len, f );
00093 }

qhandle_t trap_R_RegisterSkin const char *  name  ) 
 

Definition at line 270 of file cg_syscalls.c.

00270                                                   {
00271         return syscall( CG_R_REGISTERSKIN, name );
00272 }

void WP_RemoveSaber saberInfo_t sabers,
int  saberNum
 

Definition at line 2664 of file bg_saberLoad.c.

References BG_SI_Deactivate(), BG_SI_SetLength(), saberInfo_t::model, name, strcpy(), and WP_SaberSetDefaults().

Referenced by NPC_ParseParms(), and WP_SetSaber().

02665 {
02666         if ( !sabers )
02667         {
02668                 return;
02669         }
02670         //reset everything for this saber just in case
02671         WP_SaberSetDefaults( &sabers[saberNum] );
02672 
02673         strcpy(sabers[saberNum].name, "none");
02674         sabers[saberNum].model[0] = 0;
02675 
02676         //ent->client->ps.dualSabers = qfalse;
02677         BG_SI_Deactivate(&sabers[saberNum]);
02678         BG_SI_SetLength(&sabers[saberNum], 0.0f);
02679 //      if ( ent->weaponModel[saberNum] > 0 )
02680 //      {
02681 //              gi.G2API_RemoveGhoul2Model( ent->ghoul2, ent->weaponModel[saberNum] );
02682 //              ent->weaponModel[saberNum] = -1;
02683 //      }
02684 //      if ( saberNum == 1 )
02685 //      {
02686 //              ent->client->ps.dualSabers = qfalse;
02687 //      }
02688 }

qboolean WP_SaberBladeDoTransitionDamage saberInfo_t saber,
int  bladeNum
 

Definition at line 230 of file bg_saberLoad.c.

References qboolean, qfalse, qtrue, saberInfo_t::saberFlags2, SFL2_TRANSITION_DAMAGE, SFL2_TRANSITION_DAMAGE2, and WP_SaberBladeUseSecondBladeStyle().

00231 {
00232         if ( !WP_SaberBladeUseSecondBladeStyle( saber, bladeNum )
00233                 && (saber->saberFlags2&SFL2_TRANSITION_DAMAGE) )
00234         {//use first blade style for this blade
00235                 return qtrue;
00236         }
00237         else if ( WP_SaberBladeUseSecondBladeStyle( saber, bladeNum )
00238                 && (saber->saberFlags2&SFL2_TRANSITION_DAMAGE2) )
00239         {//use second blade style for this blade
00240                 return qtrue;
00241         }
00242         return qfalse;
00243 }

qboolean WP_SaberBladeUseSecondBladeStyle saberInfo_t saber,
int  bladeNum
 

Definition at line 215 of file bg_saberLoad.c.

References saberInfo_t::bladeStyle2Start, qboolean, qfalse, and qtrue.

Referenced by CG_AddSaberBlade(), CG_EntityEvent(), CG_SaberCompWork(), WP_SaberBladeDoTransitionDamage(), WP_SaberBounceSound(), and WP_SaberDoHit().

00216 {
00217         if ( saber )
00218         {
00219                 if ( saber->bladeStyle2Start > 0 )
00220                 {
00221                         if ( bladeNum >= saber->bladeStyle2Start )
00222                         {
00223                                 return qtrue;
00224                         }
00225                 }
00226         }
00227         return qfalse;
00228 }

qboolean WP_SaberCanTurnOffSomeBlades saberInfo_t saber  ) 
 

Definition at line 466 of file bg_saberLoad.c.

References saberInfo_t::bladeStyle2Start, saberInfo_t::numBlades, qboolean, qfalse, qtrue, saberInfo_t::saberFlags2, SFL2_NO_MANUAL_DEACTIVATE, and SFL2_NO_MANUAL_DEACTIVATE2.

Referenced by Cmd_SaberAttackCycle_f().

00467 {
00468         if ( saber->bladeStyle2Start > 0
00469                 && saber->numBlades > saber->bladeStyle2Start )
00470         {
00471                 if ( (saber->saberFlags2&SFL2_NO_MANUAL_DEACTIVATE)
00472                         && (saber->saberFlags2&SFL2_NO_MANUAL_DEACTIVATE2) )
00473                 {//all blades are always on
00474                         return qfalse;
00475                 }
00476         }
00477         else
00478         {
00479                 if ( (saber->saberFlags2&SFL2_NO_MANUAL_DEACTIVATE) )
00480                 {//all blades are always on
00481                         return qfalse;
00482                 }
00483         }
00484         //you can turn some off
00485         return qtrue;
00486 }

void WP_SaberLoadParms void   ) 
 

Definition at line 2738 of file bg_saberLoad.c.

References COM_Compress(), Com_Error(), Com_Printf(), ERR_DROP, fileHandle_t, FS_READ, MAX_SABER_DATA_SIZE, Q_strcat(), strlen(), trap_FS_FCloseFile(), trap_FS_FOpenFile(), trap_FS_GetFileList(), trap_FS_Read(), and va().

02739 {
02740         int                     len, totallen, saberExtFNLen, mainBlockLen, fileCnt, i;
02741         //const char    *filename = "ext_data/sabers.cfg";
02742         char            *holdChar, *marker;
02743         char            saberExtensionListBuf[2048];                    //      The list of file names read in
02744         fileHandle_t    f;
02745 
02746         len = 0;
02747 
02748         //remember where to store the next one
02749         totallen = mainBlockLen = len;
02750         marker = SaberParms+totallen;
02751         *marker = 0;
02752 
02753         //now load in the extra .sab extensions
02754         fileCnt = trap_FS_GetFileList("ext_data/sabers", ".sab", saberExtensionListBuf, sizeof(saberExtensionListBuf) );
02755 
02756         holdChar = saberExtensionListBuf;
02757         for ( i = 0; i < fileCnt; i++, holdChar += saberExtFNLen + 1 ) 
02758         {
02759                 saberExtFNLen = strlen( holdChar );
02760 
02761                 len = trap_FS_FOpenFile(va( "ext_data/sabers/%s", holdChar), &f, FS_READ);
02762 
02763                 if ( len == -1 ) 
02764                 {
02765                         Com_Printf( "error reading file\n" );
02766                 }
02767                 else
02768                 {
02769                         if ( (totallen + len + 1/*for the endline*/) >= MAX_SABER_DATA_SIZE ) {
02770                                 Com_Error(ERR_DROP, "Saber extensions (*.sab) are too large" );
02771                         }
02772 
02773                         trap_FS_Read(bgSaberParseTBuffer, len, f);
02774                         bgSaberParseTBuffer[len] = 0;
02775 
02776                         len = COM_Compress( bgSaberParseTBuffer );
02777 
02778                         Q_strcat( marker, MAX_SABER_DATA_SIZE-totallen, bgSaberParseTBuffer );
02779                         trap_FS_FCloseFile(f);
02780 
02781                         //get around the stupid problem of not having an endline at the bottom
02782                         //of a sab file -rww
02783                         Q_strcat(marker, MAX_SABER_DATA_SIZE-totallen, "\n");
02784                         len++;
02785 
02786                         totallen += len;
02787                         marker = SaberParms+totallen;
02788                 }
02789         }
02790 }

qboolean WP_SaberParseParm const char *  saberName,
const char *  parmname,
char *  saberData
 

Definition at line 2574 of file bg_saberLoad.c.

References BG_ParseLiteral(), COM_BeginParseSession(), COM_ParseExt(), COM_ParseString(), Com_Printf(), Q_stricmp(), qboolean, qfalse, qtrue, S_COLOR_RED, SkipBracedSection(), SkipRestOfLine(), and strcpy().

Referenced by WP_SaberValidForPlayerInMP().

02575 {
02576         const char      *token;
02577         const char      *value;
02578         const char      *p;
02579 
02580         if ( !saberName || !saberName[0] ) 
02581         {
02582                 return qfalse;
02583         }
02584 
02585         //try to parse it out
02586         p = SaberParms;
02587         COM_BeginParseSession("saberinfo");
02588 
02589         // look for the right saber
02590         while ( p )
02591         {
02592                 token = COM_ParseExt( &p, qtrue );
02593                 if ( token[0] == 0 )
02594                 {
02595                         return qfalse;
02596                 }
02597 
02598                 if ( !Q_stricmp( token, saberName ) ) 
02599                 {
02600                         break;
02601                 }
02602 
02603                 SkipBracedSection( &p );
02604         }
02605         if ( !p ) 
02606         {
02607                 return qfalse;
02608         }
02609 
02610         if ( BG_ParseLiteral( &p, "{" ) ) 
02611         {
02612                 return qfalse;
02613         }
02614                 
02615         // parse the saber info block
02616         while ( 1 ) 
02617         {
02618                 token = COM_ParseExt( &p, qtrue );
02619                 if ( !token[0] ) 
02620                 {
02621                         Com_Printf( S_COLOR_RED"ERROR: unexpected EOF while parsing '%s'\n", saberName );
02622                         return qfalse;
02623                 }
02624 
02625                 if ( !Q_stricmp( token, "}" ) ) 
02626                 {
02627                         break;
02628                 }
02629 
02630                 if ( !Q_stricmp( token, parmname ) ) 
02631                 {
02632                         if ( COM_ParseString( &p, &value ) ) 
02633                         {
02634                                 continue;
02635                         }
02636                         strcpy( saberData, value );
02637                         return qtrue;
02638                 }
02639 
02640                 SkipRestOfLine( &p );
02641                 continue;
02642         }
02643 
02644         return qfalse;
02645 }

qboolean WP_SaberParseParms const char *  SaberName,
saberInfo_t saber
 

Definition at line 617 of file bg_saberLoad.c.

References saberInfo_t::animSpeedScale, animTable, atoi(), BG_ParseLiteral(), BG_SoundIndex(), saberInfo_t::blade, saberInfo_t::bladeEffect, saberInfo_t::bladeEffect2, saberInfo_t::bladeStyle2Start, saberInfo_t::block2Sound, saberInfo_t::blockEffect, saberInfo_t::blockEffect2, saberInfo_t::blockSound, saberInfo_t::bounce2Sound, saberInfo_t::bounceSound, saberInfo_t::bowAnim, saberInfo_t::breakParryBonus, saberInfo_t::breakParryBonus2, bladeInfo_t::color, COM_BeginParseSession(), Com_Error(), COM_ParseExt(), COM_ParseFloat(), COM_ParseInt(), COM_ParseString(), Com_Printf(), saberInfo_t::damageScale, saberInfo_t::damageScale2, DEFAULT_SABER, saberInfo_t::disarmBonus, saberInfo_t::disarmBonus2, saberInfo_t::drawAnim, ERR_DROP, saberInfo_t::flourishAnim, saberInfo_t::forceRestrictions, FP_FIRST, FPTable, saberInfo_t::fullName, saberInfo_t::g2MarksShader, saberInfo_t::g2MarksShader2, saberInfo_t::g2WeaponMarkShader, saberInfo_t::g2WeaponMarkShader2, GetIDForString(), saberInfo_t::gloatAnim, saberInfo_t::hit2Sound, saberInfo_t::hitOtherEffect, saberInfo_t::hitOtherEffect2, saberInfo_t::hitPersonEffect, saberInfo_t::hitPersonEffect2, saberInfo_t::hitSound, saberInfo_t::jumpAtkBackMove, saberInfo_t::jumpAtkFwdMove, saberInfo_t::jumpAtkLeftMove, saberInfo_t::jumpAtkRightMove, saberInfo_t::jumpAtkUpMove, saberInfo_t::kataMove, saberInfo_t::knockbackScale, saberInfo_t::knockbackScale2, bladeInfo_t::lengthMax, saberInfo_t::lockBonus, LS_INVALID, LS_MOVE_MAX, saberInfo_t::lungeAtkMove, MAX_ANIMATIONS, MAX_BLADES, saberInfo_t::maxChain, saberInfo_t::meditateAnim, saberInfo_t::model, saberInfo_t::moveSpeedScale, saberInfo_t::name, NUM_FORCE_POWERS, NUM_SABERS, saberInfo_t::numBlades, saberInfo_t::parryBonus, saberInfo_t::putawayAnim, Q_stricmp(), Q_stricmpn(), qboolean, qfalse, qtrue, bladeInfo_t::radius, saberInfo_t::readyAnim, S_COLOR_RED, S_COLOR_YELLOW, saber_colors_t, SABER_SINGLE, saberInfo_t::saberFlags, saberInfo_t::saberFlags2, SaberMoveTable, SaberTable, saberType_t, SFL2_ALWAYS_BLOCK, SFL2_ALWAYS_BLOCK2, SFL2_NO_BLADE, SFL2_NO_BLADE2, SFL2_NO_CLASH_FLARE, SFL2_NO_CLASH_FLARE2, SFL2_NO_DISMEMBERMENT, SFL2_NO_DISMEMBERMENT2, SFL2_NO_DLIGHT, SFL2_NO_DLIGHT2, SFL2_NO_IDLE_EFFECT, SFL2_NO_IDLE_EFFECT2, SFL2_NO_MANUAL_DEACTIVATE, SFL2_NO_MANUAL_DEACTIVATE2, SFL2_NO_WALL_MARKS, SFL2_NO_WALL_MARKS2, SFL2_TRANSITION_DAMAGE, SFL2_TRANSITION_DAMAGE2, SFL_BOLT_TO_WRIST, SFL_BOUNCE_ON_WALLS, SFL_NO_BACK_ATTACK, SFL_NO_CARTWHEELS, SFL_NO_FLIPS, SFL_NO_KICKS, SFL_NO_MIRROR_ATTACKS, SFL_NO_PULL_ATTACK, SFL_NO_ROLL_STAB, SFL_NO_ROLLS, SFL_NO_STABDOWN, SFL_NO_WALL_FLIPS, SFL_NO_WALL_GRAB, SFL_NO_WALL_RUNS, SFL_NOT_ACTIVE_BLOCKING, SFL_NOT_DISARMABLE, SFL_NOT_LOCKABLE, SFL_NOT_THROWABLE, SFL_RETURN_DAMAGE, SFL_SINGLE_BLADE_THROWABLE, SFL_TWO_HANDED, saberInfo_t::singleBladeStyle, saberInfo_t::skin, SkipBracedSection(), SkipRestOfLine(), saberInfo_t::soundLoop, saberInfo_t::soundOff, saberInfo_t::soundOn, saberInfo_t::spinSound, saberInfo_t::splashDamage, saberInfo_t::splashDamage2, saberInfo_t::splashKnockback, saberInfo_t::splashKnockback2, saberInfo_t::splashRadius, saberInfo_t::splashRadius2, SS_NONE, SS_NUM_SABER_STYLES, strcpy(), strlen(), saberInfo_t::stylesForbidden, saberInfo_t::stylesLearned, saberInfo_t::swingSound, saberInfo_t::tauntAnim, saberInfo_t::trailStyle, saberInfo_t::trailStyle2, TranslateSaberColor(), TranslateSaberStyle(), trap_FX_RegisterEffect(), trap_R_RegisterShader(), trap_R_RegisterSkin(), saberInfo_t::type, and WP_SaberSetDefaults().

Referenced by BG_PrecacheSabersForSiegeTeam(), NPC_ParseParms(), and WP_SetSaber().

00618 {
00619         const char      *token;
00620         const char      *value;
00621         const char      *p;
00622         char    useSaber[1024];
00623         float   f;
00624         int             n;
00625         qboolean        triedDefault = qfalse;
00626         int saberMove = LS_INVALID;
00627         int     anim = -1;
00628         
00629         if ( !saber ) 
00630         {
00631                 return qfalse;
00632         }
00633         
00634         //Set defaults so that, if it fails, there's at least something there
00635         WP_SaberSetDefaults( saber );
00636 
00637         if ( !SaberName || !SaberName[0] ) 
00638         {
00639                 strcpy(useSaber, DEFAULT_SABER); //default
00640                 triedDefault = qtrue;
00641         }
00642         else
00643         {
00644                 strcpy(useSaber, SaberName);
00645         }
00646 
00647         //try to parse it out
00648         p = SaberParms;
00649         COM_BeginParseSession("saberinfo");
00650 
00651         // look for the right saber
00652         while ( p )
00653         {
00654                 token = COM_ParseExt( &p, qtrue );
00655                 if ( token[0] == 0 )
00656                 {
00657                         if (!triedDefault)
00658                         { //fall back to default and restart, should always be there
00659                                 p = SaberParms;
00660                                 COM_BeginParseSession("saberinfo");
00661                                 strcpy(useSaber, DEFAULT_SABER);
00662                                 triedDefault = qtrue;
00663                         }
00664                         else
00665                         {
00666                                 return qfalse;
00667                         }
00668                 }
00669 
00670                 if ( !Q_stricmp( token, useSaber ) ) 
00671                 {
00672                         break;
00673                 }
00674 
00675                 SkipBracedSection( &p );
00676         }
00677         if ( !p ) 
00678         { //even the default saber isn't found?
00679                 return qfalse;
00680         }
00681 
00682         //got the name we're using for sure
00683         strcpy(saber->name, useSaber);
00684 
00685         if ( BG_ParseLiteral( &p, "{" ) ) 
00686         {
00687                 return qfalse;
00688         }
00689                 
00690         // parse the saber info block
00691         while ( 1 ) 
00692         {
00693                 token = COM_ParseExt( &p, qtrue );
00694                 if ( !token[0] ) 
00695                 {
00696                         Com_Printf( S_COLOR_RED"ERROR: unexpected EOF while parsing '%s'\n", useSaber );
00697                         return qfalse;
00698                 }
00699 
00700                 if ( !Q_stricmp( token, "}" ) ) 
00701                 {
00702                         break;
00703                 }
00704 
00705                 //saber fullName
00706                 if ( !Q_stricmp( token, "name" ) ) 
00707                 {
00708                         if ( COM_ParseString( &p, &value ) ) 
00709                         {
00710                                 continue;
00711                         }
00712                         strcpy(saber->fullName, value);
00713                         continue;
00714                 }
00715 
00716                 //saber type
00717                 if ( !Q_stricmp( token, "saberType" ) ) 
00718                 {
00719                         int saberType;
00720 
00721                         if ( COM_ParseString( &p, &value ) ) 
00722                         {
00723                                 continue;
00724                         }
00725                         saberType = GetIDForString( SaberTable, value );
00726                         if ( saberType >= SABER_SINGLE && saberType <= NUM_SABERS )
00727                         {
00728                                 saber->type = (saberType_t)saberType;
00729                         }
00730                         continue;
00731                 }
00732 
00733                 //saber hilt
00734                 if ( !Q_stricmp( token, "saberModel" ) ) 
00735                 {
00736                         if ( COM_ParseString( &p, &value ) ) 
00737                         {
00738                                 continue;
00739                         }
00740                         strcpy(saber->model, value);
00741                         continue;
00742                 }
00743 
00744                 if ( !Q_stricmp( token, "customSkin" ) )
00745                 {
00746                         if ( COM_ParseString( &p, &value ) ) 
00747                         {
00748                                 continue;
00749                         }
00750                         saber->skin = trap_R_RegisterSkin(value);
00751                         continue;
00752                 }
00753 
00754                 //on sound
00755                 if ( !Q_stricmp( token, "soundOn" ) ) 
00756                 {
00757                         if ( COM_ParseString( &p, &value ) ) 
00758                         {
00759                                 continue;
00760                         }
00761                         saber->soundOn = BG_SoundIndex( (char *)value );
00762                         continue;
00763                 }
00764 
00765                 //loop sound
00766                 if ( !Q_stricmp( token, "soundLoop" ) ) 
00767                 {
00768                         if ( COM_ParseString( &p, &value ) ) 
00769                         {
00770                                 continue;
00771                         }
00772                         saber->soundLoop = BG_SoundIndex( (char *)value );
00773                         continue;
00774                 }
00775 
00776                 //off sound
00777                 if ( !Q_stricmp( token, "soundOff" ) ) 
00778                 {
00779                         if ( COM_ParseString( &p, &value ) ) 
00780                         {
00781                                 continue;
00782                         }
00783                         saber->soundOff = BG_SoundIndex( (char *)value );
00784                         continue;
00785                 }
00786 
00787                 if ( !Q_stricmp( token, "numBlades" ) ) 
00788                 {
00789                         if ( COM_ParseInt( &p, &n ) ) 
00790                         {
00791                                 SkipRestOfLine( &p );
00792                                 continue;
00793                         }
00794                         if ( n < 1 || n > MAX_BLADES )
00795                         {
00796                                 Com_Error(ERR_DROP, "WP_SaberParseParms: saber %s has illegal number of blades (%d) max: %d", useSaber, n, MAX_BLADES );
00797                                 continue;
00798                         }
00799                         saber->numBlades = n;
00800                         continue;
00801                 }
00802 
00803                 // saberColor
00804                 if ( !Q_stricmpn( token, "saberColor", 10 ) ) 
00805                 {
00806                         if (strlen(token)==10)
00807                         {
00808                                 n = -1;
00809                         }
00810                         else if (strlen(token)==11)
00811                         {
00812                                 n = atoi(&token[10])-1;
00813                                 if (n > 7 || n < 1 )
00814                                 {
00815                                         Com_Printf( S_COLOR_YELLOW"WARNING: bad saberColor '%s' in %s\n", token, useSaber );
00816                                         continue;
00817                                 }
00818                         }
00819                         else
00820                         {
00821                                 Com_Printf( S_COLOR_YELLOW"WARNING: bad saberColor '%s' in %s\n", token, useSaber );
00822                                 continue;
00823                         }
00824 
00825                         if ( COM_ParseString( &p, &value ) )    //read the color
00826                         {
00827                                 continue;
00828                         }
00829 
00830                         if (n==-1)
00831                         {//NOTE: this fills in the rest of the blades with the same color by default
00832                                 saber_colors_t color = TranslateSaberColor( value );
00833                                 for ( n = 0; n < MAX_BLADES; n++ )
00834                                 {
00835                                         saber->blade[n].color = color;
00836                                 }
00837                         } else 
00838                         {
00839                                 saber->blade[n].color = TranslateSaberColor( value );
00840                         }
00841                         continue;
00842                 }
00843 
00844                 //saber length
00845                 if ( !Q_stricmpn( token, "saberLength", 11 ) ) 
00846                 {
00847                         if (strlen(token)==11)
00848                         {
00849                                 n = -1;
00850                         }
00851                         else if (strlen(token)==12)
00852                         {
00853                                 n = atoi(&token[11])-1;
00854                                 if (n > 7 || n < 1 )
00855                                 {
00856                                         Com_Printf( S_COLOR_YELLOW"WARNING: bad saberLength '%s' in %s\n", token, useSaber );
00857                                         continue;
00858                                 }
00859                         }
00860                         else
00861                         {
00862                                 Com_Printf( S_COLOR_YELLOW"WARNING: bad saberLength '%s' in %s\n", token, useSaber );
00863                                 continue;
00864                         }
00865 
00866                         if ( COM_ParseFloat( &p, &f ) ) 
00867                         {
00868                                 SkipRestOfLine( &p );
00869                                 continue;
00870                         }
00871                         //cap
00872                         if ( f < 4.0f )
00873                         {
00874                                 f = 4.0f;
00875                         }
00876 
00877                         if (n==-1)
00878                         {//NOTE: this fills in the rest of the blades with the same length by default
00879                                 for ( n = 0; n < MAX_BLADES; n++ )
00880