Home » SIRTECH CLASSICS » Jagged Alliance: Unfinished Business » Vanilla Modding » JA2 Source Code Digging: Adding new teams?
|
|
| Re: JA2 Source Code Digging: Adding new teams?[message #186329]
|
Mon, 26 May 2008 03:08 
|
|
Shanga |
  |
Messages:3475
Registered:January 2000 Location: Danubia |
|
|
And another function that looks like the one responsible for "coloring" the various bodytypes (I might be wrong, but I am no coder so all i can do is scout):
https://81.169.133.124/source/ja2/branches/Jones/html/Soldier_01Control_8cpp-source.html#l06223
Quote:
06120 ///////////////////////////////////////////////////////
06121 //PALETTE REPLACEMENT FUNCTIONS
06122 ///////////////////////////////////////////////////////
06123 BOOLEAN LoadPaletteData( )
06124 {
06125 HWFILE hFile;
06126 UINT32 cnt, cnt2;
06127
06128 hFile = FileOpen( PALETTEFILENAME, FILE_ACCESS_READ, FALSE );
06129
06130 // Read # of types
06131 if ( !FileRead( hFile, &guiNumPaletteSubRanges, sizeof( guiNumPaletteSubRanges ), (UINT32 *)NULL ) )
06132 {
06133 return( FALSE );
06134 }
06135
06136 // Malloc!
06137 gpPaletteSubRanges = (PaletteSubRangeType *) MemAlloc( sizeof( PaletteSubRangeType ) * guiNumPaletteSubRanges );
06138 gubpNumReplacementsPerRange = (UINT8 *) MemAlloc( sizeof( UINT8 ) * guiNumPaletteSubRanges );
06139
06140 // Read # of types for each!
06141 for ( cnt = 0; cnt < guiNumPaletteSubRanges; cnt++ )
06142 {
06143 if ( !FileRead( hFile, &gubpNumReplacementsPerRange[ cnt ], sizeof( UINT8 ), (UINT32 *)NULL ) )
06144 {
06145 return( FALSE );
06146 }
06147 }
06148
06149 // Loop for each one, read in data
06150 for ( cnt = 0; cnt < guiNumPaletteSubRanges; cnt++ )
06151 {
06152 if ( !FileRead( hFile, &gpPaletteSubRanges[ cnt ].ubStart, sizeof( UINT8 ), (UINT32 *)NULL ) )
06153 {
06154 return( FALSE );
06155 }
06156 if ( !FileRead( hFile, &gpPaletteSubRanges[ cnt ].ubEnd, sizeof( UINT8 ), (UINT32 *)NULL ) )
06157 {
06158 return( FALSE );
06159 }
06160 }
06161
06162
06163 // Read # of palettes
06164 if ( !FileRead( hFile, &guiNumReplacements, sizeof( guiNumReplacements ), (UINT32 *)NULL ) )
06165 {
06166 return( FALSE );
06167 }
06168
06169 // Malloc!
06170 gpPalRep = (PaletteReplacementType *) MemAlloc( sizeof( PaletteReplacementType ) * guiNumReplacements );
06171
06172 // Read!
06173 for ( cnt = 0; cnt < guiNumReplacements; cnt++ )
06174 {
06175 // type
06176 if ( !FileRead( hFile, &gpPalRep[ cnt ].ubType, sizeof( gpPalRep[ cnt ].ubType ), (UINT32 *)NULL ) )
06177 {
06178 return( FALSE );
06179 }
06180
06181 if ( !FileRead( hFile, &gpPalRep[ cnt ].ID, sizeof( gpPalRep[ cnt ].ID ), (UINT32 *)NULL ) )
06182 {
06183 return( FALSE );
06184 }
06185
06186 // # entries
06187 if ( !FileRead( hFile, &gpPalRep[ cnt ].ubPaletteSize, sizeof( gpPalRep[ cnt ].ubPaletteSize ), (UINT32 *)NULL ) )
06188 {
06189 return( FALSE );
06190 }
06191
06192 // Malloc
06193 gpPalRep[ cnt ].r = (UINT8 *) MemAlloc( gpPalRep[ cnt ].ubPaletteSize );
06194 CHECKF( gpPalRep[ cnt ].r != NULL );
06195 gpPalRep[ cnt ].g = (UINT8 *) MemAlloc( gpPalRep[ cnt ].ubPaletteSize );
06196 CHECKF( gpPalRep[ cnt ].g != NULL );
06197 gpPalRep[ cnt ].b = (UINT8 *) MemAlloc( gpPalRep[ cnt ].ubPaletteSize );
06198 CHECKF( gpPalRep[ cnt ].b != NULL );
06199
06200 for( cnt2 = 0; cnt2 < gpPalRep[ cnt ].ubPaletteSize; cnt2++ )
06201 {
06202 if ( !FileRead( hFile, &gpPalRep[ cnt ].r[ cnt2 ], sizeof( UINT8 ), (UINT32 *)NULL ) )
06203 {
06204 return( FALSE );
06205 }
06206 if ( !FileRead( hFile, &gpPalRep[ cnt ].g[ cnt2 ], sizeof( UINT8 ), (UINT32 *)NULL ) )
06207 {
06208 return( FALSE );
06209 }
06210 if ( !FileRead( hFile, &gpPalRep[ cnt ].b[ cnt2 ], sizeof( UINT8 ), (UINT32 *)NULL ) )
06211 {
06212 return( FALSE );
06213 }
06214 }
06215
06216 }
06217
06218 FileClose( hFile );
06219
06220 return( TRUE );
06221 }
06222
06223 BOOLEAN SetPaletteReplacement( SGPPaletteEntry *p8BPPPalette, PaletteRepID aPalRep )
06224 {
06225 UINT32 cnt2;
06226 UINT8 ubType;
06227 UINT8 ubPalIndex;
06228
06229 CHECKF( GetPaletteRepIndexFromID( aPalRep, &ubPalIndex ) );
06230
06231 // Get range type
06232 ubType = gpPalRep[ ubPalIndex ].ubType;
06233
06234 for ( cnt2 = gpPaletteSubRanges[ ubType ].ubStart; cnt2 <= gpPaletteSubRanges[ ubType ].ubEnd; cnt2++ )
06235 {
06236 p8BPPPalette[ cnt2 ].peRed = gpPalRep[ ubPalIndex ].r[ cnt2 - gpPaletteSubRanges[ ubType ].ubStart ];
06237 p8BPPPalette[ cnt2 ].peGreen = gpPalRep[ ubPalIndex ].g[ cnt2 - gpPaletteSubRanges[ ubType ].ubStart ];
06238 p8BPPPalette[ cnt2 ].peBlue = gpPalRep[ ubPalIndex ].b[ cnt2 - gpPaletteSubRanges[ ubType ].ubStart ];
06239 }
06240
06241 return( TRUE );
06242 }
06243
06244
06245 BOOLEAN DeletePaletteData( )
06246 {
06247 UINT32 cnt;
06248
06249 // Free!
06250 if ( gpPaletteSubRanges != NULL )
06251 {
06252 MemFree( gpPaletteSubRanges );
06253 gpPaletteSubRanges = NULL;
06254 }
06255
06256 if ( gubpNumReplacementsPerRange != NULL )
06257 {
06258 MemFree( gubpNumReplacementsPerRange );
06259 gubpNumReplacementsPerRange = NULL;
06260 }
06261
06262
06263 for ( cnt = 0; cnt < guiNumReplacements; cnt++ )
06264 {
06265 // Free
06266 if ( gpPalRep[ cnt ].r != NULL )
06267 {
06268 MemFree( gpPalRep[ cnt ].r );
06269 gpPalRep[ cnt ].r = NULL;
06270 }
06271 if ( gpPalRep[ cnt ].g != NULL )
06272 {
06273 MemFree( gpPalRep[ cnt ].g );
06274 gpPalRep[ cnt ].g = NULL;
06275 }
06276 if ( gpPalRep[ cnt ].b != NULL )
06277 {
06278 MemFree( gpPalRep[ cnt ].b );
06279 gpPalRep[ cnt ].b = NULL;
06280 }
06281 }
06282
06283 // Free
06284 if ( gpPalRep != NULL )
06285 {
06286 MemFree( gpPalRep );
06287 gpPalRep = NULL;
06288 }
06289
06290 return( TRUE );
06291 }
06292
06293
06294 BOOLEAN GetPaletteRepIndexFromID( PaletteRepID aPalRep, UINT8 *pubPalIndex )
06295 {
06296 UINT32 cnt;
06297
06298 // Check if type exists
06299 for ( cnt = 0; cnt < guiNumReplacements; cnt++ )
06300 {
06301 if ( COMPARE_PALETTEREP_ID( aPalRep, gpPalRep[ cnt ].ID ) )
06302 {
06303 *pubPalIndex = ( UINT8 )cnt;
06304 return( TRUE );
06305 }
06306 }
06307
06308 DebugMsg( TOPIC_JA2, DBG_LEVEL_3, "Invalid Palette Replacement ID given");
06309 return( FALSE );
06310 }
Report message to a moderator
|
|
|
|
|
|
|
|
|
|
|
Goto Forum:
Current Time: Thu Jun 11 05:28:31 GMT+3 2026
Total time taken to generate the page: 0.00612 seconds
|