X-Git-Url: https://de.git.xonotic.org/?a=blobdiff_plain;f=tools%2Fquake2%2Fqdata%2Fsprites.c;fp=tools%2Fquake2%2Fqdata%2Fsprites.c;h=16eb00c687db7106b27728cdb0503aad580bb676;hb=e4287c28bb2dafedc81c66e63951d947cfbeb225;hp=a70f00745ffe9660516dd70867873e9d290877b9;hpb=203343b01a7ad87cb3d136689c9936ff5bc23c01;p=xonotic%2Fnetradiant.git diff --git a/tools/quake2/qdata/sprites.c b/tools/quake2/qdata/sprites.c index a70f0074..16eb00c6 100644 --- a/tools/quake2/qdata/sprites.c +++ b/tools/quake2/qdata/sprites.c @@ -1,228 +1,227 @@ /* -Copyright (C) 1999-2006 Id Software, Inc. and contributors. -For a list of contributors, see the accompanying CONTRIBUTORS file. + Copyright (C) 1999-2006 Id Software, Inc. and contributors. + For a list of contributors, see the accompanying CONTRIBUTORS file. -This file is part of GtkRadiant. + This file is part of GtkRadiant. -GtkRadiant is free software; you can redistribute it and/or modify -it under the terms of the GNU General Public License as published by -the Free Software Foundation; either version 2 of the License, or -(at your option) any later version. + GtkRadiant is free software; you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation; either version 2 of the License, or + (at your option) any later version. -GtkRadiant is distributed in the hope that it will be useful, -but WITHOUT ANY WARRANTY; without even the implied warranty of -MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -GNU General Public License for more details. + GtkRadiant is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. -You should have received a copy of the GNU General Public License -along with GtkRadiant; if not, write to the Free Software -Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA -*/ + You should have received a copy of the GNU General Public License + along with GtkRadiant; if not, write to the Free Software + Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA + */ #include "qdata.h" #include "inout.h" -#define MAX_SPRFRAMES MAX_MD2SKINS +#define MAX_SPRFRAMES MAX_MD2SKINS -dsprite_t sprite; -dsprframe_t frames[MAX_SPRFRAMES]; +dsprite_t sprite; +dsprframe_t frames[MAX_SPRFRAMES]; -byte *byteimage, *lbmpalette; -int byteimagewidth, byteimageheight; +byte *byteimage, *lbmpalette; +int byteimagewidth, byteimageheight; -char spritename[1024]; +char spritename[1024]; -void FinishSprite (void); -void Cmd_Spritename (void); +void FinishSprite( void ); +void Cmd_Spritename( void ); /* -============== -FinishSprite -============== -*/ -void FinishSprite (void) -{ - FILE *spriteouthandle; - int i, curframe; - dsprite_t spritetemp; - char savename[1024]; - - if (sprite.numframes == 0) + ============== + FinishSprite + ============== + */ +void FinishSprite( void ){ + FILE *spriteouthandle; + int i, curframe; + dsprite_t spritetemp; + char savename[1024]; + + if ( sprite.numframes == 0 ) { return; + } + + if ( !strlen( spritename ) ) { + Error( "Didn't name sprite file" ); + } - if (!strlen(spritename)) - Error ("Didn't name sprite file"); - - sprintf (savename, "%s%s.sp2", gamedir, spritename); + sprintf( savename, "%s%s.sp2", gamedir, spritename ); - if (g_release) - { - char name[1024]; + if ( g_release ) { + char name[1024]; - sprintf (name, "%s.sp2", spritename); - ReleaseFile (name); - spritename[0] = 0; // clear for a new sprite + sprintf( name, "%s.sp2", spritename ); + ReleaseFile( name ); + spritename[0] = 0; // clear for a new sprite sprite.numframes = 0; return; } - printf ("saving in %s\n", savename); - CreatePath (savename); - spriteouthandle = SafeOpenWrite (savename); + printf( "saving in %s\n", savename ); + CreatePath( savename ); + spriteouthandle = SafeOpenWrite( savename ); // // write out the sprite header // - spritetemp.ident = LittleLong (IDSPRITEHEADER); - spritetemp.version = LittleLong (SPRITE_VERSION); - spritetemp.numframes = LittleLong (sprite.numframes); + spritetemp.ident = LittleLong( IDSPRITEHEADER ); + spritetemp.version = LittleLong( SPRITE_VERSION ); + spritetemp.numframes = LittleLong( sprite.numframes ); - SafeWrite (spriteouthandle, &spritetemp, 12); + SafeWrite( spriteouthandle, &spritetemp, 12 ); // // write out the frames // curframe = 0; - for (i=0 ; i 256) || (h > 256)) - Error ("Sprite has a dimension longer than 256"); + if ( ( w > 256 ) || ( h > 256 ) ) { + Error( "Sprite has a dimension longer than 256" ); + } - xh = xl+w; - yh = yl+h; + xh = xl + w; + yh = yl + h; - if (sprite.numframes >= MAX_SPRFRAMES) - Error ("Too many frames; increase MAX_SPRFRAMES\n"); + if ( sprite.numframes >= MAX_SPRFRAMES ) { + Error( "Too many frames; increase MAX_SPRFRAMES\n" ); + } pframe = &frames[sprite.numframes]; pframe->width = w; pframe->height = h; pframe->origin_x = ox; pframe->origin_y = oy; - sprintf (pframe->name, "%s_%i.pcx", spritename, sprite.numframes); - sprintf (savename, "%s%s_%i.pcx", gamedir, spritename, sprite.numframes); + sprintf( pframe->name, "%s_%i.pcx", spritename, sprite.numframes ); + sprintf( savename, "%s%s_%i.pcx", gamedir, spritename, sprite.numframes ); sprite.numframes++; - if (g_release) - { - ReleaseFile (pframe->name); + if ( g_release ) { + ReleaseFile( pframe->name ); return; } // crop it to the proper size - cropped = malloc (w*h); - for (y=0 ; y