Cleanup
This commit is contained in:
parent
5d87f0f520
commit
a7519549f7
11 changed files with 1228 additions and 1258 deletions
|
@ -125,7 +125,7 @@ global void LoadTileset(void)
|
|||
//
|
||||
buf = alloca(strlen(Tilesets[i]->ImageFile) + 9 + 1);
|
||||
strcat(strcpy(buf, "graphics/"), Tilesets[i]->ImageFile);
|
||||
ShowLoadProgress("\tTileset `%s'\n", Tilesets[i]->ImageFile);
|
||||
ShowLoadProgress("Tileset `%s'", Tilesets[i]->ImageFile);
|
||||
TheMap.TileData = LoadGraphic(buf);
|
||||
#ifdef USE_OPENGL
|
||||
MakeTexture(TheMap.TileData, TheMap.TileData->Width, TheMap.TileData->Height);
|
||||
|
|
|
@ -87,46 +87,46 @@ global void LoadConstructions(void)
|
|||
const char* file;
|
||||
Construction** cop;
|
||||
|
||||
if( (cop=Constructions) ) {
|
||||
while( *cop ) {
|
||||
if( !(*cop)->Ident ) {
|
||||
if ((cop = Constructions)) {
|
||||
while (*cop) {
|
||||
if (!(*cop)->Ident) {
|
||||
continue;
|
||||
}
|
||||
file=(*cop)->File[TheMap.Terrain].File;
|
||||
if( file ) { // default one
|
||||
(*cop)->Width=(*cop)->File[TheMap.Terrain].Width;
|
||||
(*cop)->Height=(*cop)->File[TheMap.Terrain].Height;
|
||||
file = (*cop)->File[TheMap.Terrain].File;
|
||||
if (file) { // default one
|
||||
(*cop)->Width = (*cop)->File[TheMap.Terrain].Width;
|
||||
(*cop)->Height = (*cop)->File[TheMap.Terrain].Height;
|
||||
} else {
|
||||
file=(*cop)->File[0].File;
|
||||
(*cop)->Width=(*cop)->File[0].Width;
|
||||
(*cop)->Height=(*cop)->File[0].Height;
|
||||
file = (*cop)->File[0].File;
|
||||
(*cop)->Width = (*cop)->File[0].Width;
|
||||
(*cop)->Height = (*cop)->File[0].Height;
|
||||
}
|
||||
if( *file ) {
|
||||
if (*file) {
|
||||
char* buf;
|
||||
|
||||
buf=alloca(strlen(file)+9+1);
|
||||
file=strcat(strcpy(buf,"graphics/"),file);
|
||||
ShowLoadProgress("\tConstruction %s\n",file);
|
||||
(*cop)->Sprite=LoadSprite(file
|
||||
,(*cop)->Width,(*cop)->Height);
|
||||
buf = alloca(strlen(file) + 9 + 1);
|
||||
file = strcat(strcpy(buf, "graphics/"), file);
|
||||
ShowLoadProgress("Construction %s", file);
|
||||
(*cop)->Sprite = LoadSprite(file,
|
||||
(*cop)->Width, (*cop)->Height);
|
||||
}
|
||||
file=(*cop)->ShadowFile[TheMap.Terrain].File;
|
||||
if( file ) {
|
||||
(*cop)->ShadowWidth=(*cop)->ShadowFile[TheMap.Terrain].Width;
|
||||
(*cop)->ShadowHeight=(*cop)->ShadowFile[TheMap.Terrain].Height;
|
||||
file = (*cop)->ShadowFile[TheMap.Terrain].File;
|
||||
if (file) {
|
||||
(*cop)->ShadowWidth = (*cop)->ShadowFile[TheMap.Terrain].Width;
|
||||
(*cop)->ShadowHeight = (*cop)->ShadowFile[TheMap.Terrain].Height;
|
||||
} else {
|
||||
file=(*cop)->ShadowFile[0].File;
|
||||
(*cop)->ShadowWidth=(*cop)->ShadowFile[0].Width;
|
||||
(*cop)->ShadowHeight=(*cop)->ShadowFile[0].Height;
|
||||
file = (*cop)->ShadowFile[0].File;
|
||||
(*cop)->ShadowWidth = (*cop)->ShadowFile[0].Width;
|
||||
(*cop)->ShadowHeight = (*cop)->ShadowFile[0].Height;
|
||||
}
|
||||
if( file && *file ) {
|
||||
char *buf;
|
||||
if (file && *file) {
|
||||
char* buf;
|
||||
|
||||
buf=alloca(strlen(file)+9+1);
|
||||
file=strcat(strcpy(buf,"graphics/"),file);
|
||||
ShowLoadProgress("\tConstruction %s\n",file);
|
||||
(*cop)->ShadowSprite=LoadSprite(file
|
||||
,(*cop)->ShadowWidth,(*cop)->ShadowHeight);
|
||||
buf = alloca(strlen(file) + 9 + 1);
|
||||
file = strcat(strcpy(buf, "graphics/"), file);
|
||||
ShowLoadProgress("Construction %s", file);
|
||||
(*cop)->ShadowSprite = LoadSprite(file,
|
||||
(*cop)->ShadowWidth, (*cop)->ShadowHeight);
|
||||
}
|
||||
++cop;
|
||||
}
|
||||
|
@ -146,72 +146,72 @@ global void SaveConstructions(CLFile* file)
|
|||
Construction** cop;
|
||||
ConstructionFrame* cframe;
|
||||
|
||||
CLprintf(file,"\n;;; -----------------------------------------\n");
|
||||
CLprintf(file,";;; MODULE: constructions $Id$\n\n");
|
||||
CLprintf(file, "\n;;; -----------------------------------------\n");
|
||||
CLprintf(file, ";;; MODULE: constructions $Id$\n\n");
|
||||
|
||||
// FIXME: needed?
|
||||
|
||||
//
|
||||
// Dump table wc2 construction numbers -> internal symbol.
|
||||
//
|
||||
if( (cp=ConstructionWcNames) ) {
|
||||
CLprintf(file,"(define-construction-wc-names");
|
||||
if ((cp = ConstructionWcNames)) {
|
||||
CLprintf(file, "(define-construction-wc-names");
|
||||
|
||||
i=90;
|
||||
while( *cp ) {
|
||||
if( i+strlen(*cp)>79 ) {
|
||||
i=CLprintf(file,"\n ");
|
||||
i = 90;
|
||||
while (*cp) {
|
||||
if (i + strlen(*cp) > 79) {
|
||||
i = CLprintf(file, "\n ");
|
||||
}
|
||||
i+=CLprintf(file," '%s",*cp++);
|
||||
i += CLprintf(file, " '%s", *cp++);
|
||||
}
|
||||
CLprintf(file,")\n\n");
|
||||
CLprintf(file, ")\n\n");
|
||||
}
|
||||
|
||||
//
|
||||
// Dump table of all constructions
|
||||
//
|
||||
if( (cop=Constructions) ) {
|
||||
while( *cop ) {
|
||||
if( !(*cop)->Ident ) {
|
||||
if ((cop = Constructions)) {
|
||||
while (*cop) {
|
||||
if (!(*cop)->Ident) {
|
||||
continue;
|
||||
}
|
||||
CLprintf(file,"(define-construction '%s\n",(*cop)->Ident);
|
||||
for( j=0; j<TilesetMax; ++j ) {
|
||||
if( !(*cop)->File[j].File ) {
|
||||
CLprintf(file, "(define-construction '%s\n", (*cop)->Ident);
|
||||
for (j = 0; j < TilesetMax; ++j) {
|
||||
if (!(*cop)->File[j].File) {
|
||||
continue;
|
||||
}
|
||||
CLprintf(file," 'file '(\n");
|
||||
CLprintf(file," tileset %s\n",Tilesets[j]->Class);
|
||||
CLprintf(file," file \"%s\"\n",(*cop)->File[j].File);
|
||||
CLprintf(file," size (%d %d))\n",(*cop)->File[j].Width,
|
||||
(*cop)->File[j].Height);
|
||||
CLprintf(file, " 'file '(\n");
|
||||
CLprintf(file, " tileset %s\n", Tilesets[j]->Class);
|
||||
CLprintf(file, " file \"%s\"\n", (*cop)->File[j].File);
|
||||
CLprintf(file, " size (%d %d))\n", (*cop)->File[j].Width,
|
||||
(*cop)->File[j].Height);
|
||||
}
|
||||
for( j=0; j<TilesetMax; ++j ) {
|
||||
if( !(*cop)->ShadowFile[j].File ) {
|
||||
for (j = 0; j < TilesetMax; ++j) {
|
||||
if (!(*cop)->ShadowFile[j].File) {
|
||||
continue;
|
||||
}
|
||||
CLprintf(file," 'shadow-file '(\n");
|
||||
CLprintf(file," tileset %s\n",Tilesets[j]->Class);
|
||||
CLprintf(file," file \"%s\"\n",(*cop)->ShadowFile[j].File);
|
||||
CLprintf(file," size (%d %d))\n",(*cop)->ShadowFile[j].Width,
|
||||
(*cop)->ShadowFile[j].Height);
|
||||
CLprintf(file, " 'shadow-file '(\n");
|
||||
CLprintf(file, " tileset %s\n", Tilesets[j]->Class);
|
||||
CLprintf(file, " file \"%s\"\n", (*cop)->ShadowFile[j].File);
|
||||
CLprintf(file, " size (%d %d))\n", (*cop)->ShadowFile[j].Width,
|
||||
(*cop)->ShadowFile[j].Height);
|
||||
}
|
||||
cframe=(*cop)->Frames;
|
||||
if( cframe ) {
|
||||
CLprintf(file," 'constructions (list");
|
||||
while( cframe ) {
|
||||
CLprintf(file,"\n '(percent %d\n",cframe->Percent);
|
||||
if( cframe->File==ConstructionFileConstruction ) {
|
||||
CLprintf(file," file construction\n");
|
||||
cframe = (*cop)->Frames;
|
||||
if (cframe) {
|
||||
CLprintf(file, " 'constructions (list");
|
||||
while (cframe) {
|
||||
CLprintf(file, "\n '(percent %d\n", cframe->Percent);
|
||||
if (cframe->File == ConstructionFileConstruction) {
|
||||
CLprintf(file, " file construction\n");
|
||||
} else {
|
||||
CLprintf(file," file main\n");
|
||||
CLprintf(file, " file main\n");
|
||||
}
|
||||
CLprintf(file," frame %d)",cframe->Frame);
|
||||
cframe=cframe->Next;
|
||||
CLprintf(file, " frame %d)",cframe->Frame);
|
||||
cframe = cframe->Next;
|
||||
}
|
||||
CLprintf(file,")\n");
|
||||
CLprintf(file, ")\n");
|
||||
}
|
||||
CLprintf(file,")\n\n");
|
||||
CLprintf(file, ")\n\n");
|
||||
++cop;
|
||||
}
|
||||
}
|
||||
|
@ -231,45 +231,45 @@ global void CleanConstructions(void)
|
|||
//
|
||||
// Mapping original construction numbers in puds to our internal strings
|
||||
//
|
||||
if( (cp=ConstructionWcNames) ) { // Free all old names
|
||||
while( *cp ) {
|
||||
if ((cp = ConstructionWcNames)) { // Free all old names
|
||||
while (*cp) {
|
||||
free(*cp++);
|
||||
}
|
||||
free(ConstructionWcNames);
|
||||
ConstructionWcNames=NULL;
|
||||
ConstructionWcNames = NULL;
|
||||
}
|
||||
|
||||
//
|
||||
// Free the construction table.
|
||||
//
|
||||
if( (cop=Constructions) ) {
|
||||
while( *cop ) {
|
||||
if( (*cop)->Ident ) {
|
||||
if ((cop = Constructions)) {
|
||||
while (*cop) {
|
||||
if ((*cop)->Ident) {
|
||||
free((*cop)->Ident);
|
||||
}
|
||||
for( j=0; j<TilesetMax; ++j ) {
|
||||
if( (*cop)->File[j].File ) {
|
||||
for (j = 0; j < TilesetMax; ++j) {
|
||||
if ((*cop)->File[j].File) {
|
||||
free((*cop)->File[j].File);
|
||||
}
|
||||
}
|
||||
VideoSaveFree((*cop)->Sprite);
|
||||
for( j=0; j<TilesetMax; ++j ) {
|
||||
if( (*cop)->ShadowFile[j].File ) {
|
||||
for (j = 0; j < TilesetMax; ++j) {
|
||||
if ((*cop)->ShadowFile[j].File) {
|
||||
free((*cop)->ShadowFile[j].File);
|
||||
}
|
||||
}
|
||||
VideoSaveFree((*cop)->ShadowSprite);
|
||||
cframe=(*cop)->Frames;
|
||||
while( cframe ) {
|
||||
tmp=cframe->Next;
|
||||
cframe = (*cop)->Frames;
|
||||
while (cframe) {
|
||||
tmp = cframe->Next;
|
||||
free(cframe);
|
||||
cframe=tmp;
|
||||
cframe = tmp;
|
||||
}
|
||||
free(*cop);
|
||||
++cop;
|
||||
}
|
||||
free(Constructions);
|
||||
Constructions=NULL;
|
||||
Constructions = NULL;
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -284,9 +284,9 @@ global Construction* ConstructionByIdent(const char* ident)
|
|||
{
|
||||
Construction** cop;
|
||||
|
||||
if( (cop=Constructions) ) {
|
||||
while( *cop ) {
|
||||
if( (*cop)->Ident && !strcmp(ident,(*cop)->Ident) ) {
|
||||
if ((cop = Constructions)) {
|
||||
while (*cop) {
|
||||
if ((*cop)->Ident && !strcmp(ident, (*cop)->Ident)) {
|
||||
return *cop;
|
||||
}
|
||||
++cop;
|
||||
|
@ -318,8 +318,8 @@ local SCM CclDefineConstructionWcNames(SCM list)
|
|||
int i;
|
||||
char** cp;
|
||||
|
||||
if( (cp=ConstructionWcNames) ) { // Free all old names
|
||||
while( *cp ) {
|
||||
if ((cp = ConstructionWcNames)) { // Free all old names
|
||||
while (*cp) {
|
||||
free(*cp++);
|
||||
}
|
||||
free(ConstructionWcNames);
|
||||
|
@ -328,13 +328,13 @@ local SCM CclDefineConstructionWcNames(SCM list)
|
|||
//
|
||||
// Get new table.
|
||||
//
|
||||
i=gh_length(list);
|
||||
ConstructionWcNames=cp=malloc((i+1)*sizeof(char*));
|
||||
while( i-- ) {
|
||||
*cp++=gh_scm2newstr(gh_car(list),NULL);
|
||||
list=gh_cdr(list);
|
||||
i = gh_length(list);
|
||||
ConstructionWcNames = cp = malloc((i + 1) * sizeof(char*));
|
||||
while (i--) {
|
||||
*cp++ = gh_scm2newstr(gh_car(list), NULL);
|
||||
list = gh_cdr(list);
|
||||
}
|
||||
*cp=NULL;
|
||||
*cp = NULL;
|
||||
|
||||
return SCM_UNSPECIFIED;
|
||||
}
|
||||
|
@ -357,162 +357,162 @@ local SCM CclDefineConstruction(SCM list)
|
|||
|
||||
// Slot identifier
|
||||
|
||||
str=gh_scm2newstr(gh_car(list),NULL);
|
||||
list=gh_cdr(list);
|
||||
str = gh_scm2newstr(gh_car(list), NULL);
|
||||
list = gh_cdr(list);
|
||||
|
||||
for( i=0; ConstructionWcNames[i]; ++i ) {
|
||||
if( !strcmp(ConstructionWcNames[i],str) ) {
|
||||
for (i = 0; ConstructionWcNames[i]; ++i) {
|
||||
if (!strcmp(ConstructionWcNames[i], str)) {
|
||||
break;
|
||||
}
|
||||
}
|
||||
if( !ConstructionWcNames[i] ) {
|
||||
if (!ConstructionWcNames[i]) {
|
||||
DebugLevel0Fn("Construction not found.\n");
|
||||
free(str);
|
||||
return SCM_UNSPECIFIED;
|
||||
}
|
||||
|
||||
if( (cop=Constructions)==NULL ) {
|
||||
Constructions=malloc(2*sizeof(Construction*));
|
||||
Constructions[0]=calloc(1,sizeof(Construction));
|
||||
Constructions[1]=NULL;
|
||||
construction=Constructions[0];
|
||||
if ((cop = Constructions) == NULL) {
|
||||
Constructions = malloc(2 * sizeof(Construction*));
|
||||
Constructions[0] = calloc(1, sizeof(Construction));
|
||||
Constructions[1] = NULL;
|
||||
construction = Constructions[0];
|
||||
} else {
|
||||
for( i=0; *cop; ++i,++cop ) {
|
||||
for (i = 0; *cop; ++i, ++cop) {
|
||||
}
|
||||
Constructions=realloc(Constructions,(i+2)*sizeof(Construction*));
|
||||
Constructions[i]=calloc(1,sizeof(Construction));
|
||||
Constructions[i+1]=NULL;
|
||||
construction=Constructions[i];
|
||||
Constructions = realloc(Constructions, (i + 2) * sizeof(Construction*));
|
||||
Constructions[i] = calloc(1, sizeof(Construction));
|
||||
Constructions[i+1] = NULL;
|
||||
construction = Constructions[i];
|
||||
}
|
||||
construction->OType=ConstructionType;
|
||||
construction->Ident=str;
|
||||
construction->OType = ConstructionType;
|
||||
construction->Ident = str;
|
||||
|
||||
//
|
||||
// Parse the arguments, in tagged format.
|
||||
//
|
||||
while( !gh_null_p(list) ) {
|
||||
while (!gh_null_p(list)) {
|
||||
int files;
|
||||
|
||||
value=gh_car(list);
|
||||
list=gh_cdr(list);
|
||||
value = gh_car(list);
|
||||
list = gh_cdr(list);
|
||||
|
||||
if( (files=gh_eq_p(value,gh_symbol2scm("file")))
|
||||
|| gh_eq_p(value,gh_symbol2scm("shadow-file")) ) {
|
||||
if ((files = gh_eq_p(value, gh_symbol2scm("file"))) ||
|
||||
gh_eq_p(value, gh_symbol2scm("shadow-file"))) {
|
||||
int tileset;
|
||||
char* file;
|
||||
int w;
|
||||
int h;
|
||||
|
||||
tileset=0;
|
||||
file=NULL;
|
||||
w=0;
|
||||
h=0;
|
||||
tileset = 0;
|
||||
file = NULL;
|
||||
w = 0;
|
||||
h = 0;
|
||||
|
||||
sublist=gh_car(list);
|
||||
while( !gh_null_p(sublist) ) {
|
||||
value=gh_car(sublist);
|
||||
sublist=gh_cdr(sublist);
|
||||
sublist = gh_car(list);
|
||||
while (!gh_null_p(sublist)) {
|
||||
value = gh_car(sublist);
|
||||
sublist = gh_cdr(sublist);
|
||||
|
||||
if( gh_eq_p(value,gh_symbol2scm("tileset")) ) {
|
||||
str=gh_scm2newstr(gh_car(sublist),NULL);
|
||||
sublist=gh_cdr(sublist);
|
||||
if (gh_eq_p(value, gh_symbol2scm("tileset"))) {
|
||||
str = gh_scm2newstr(gh_car(sublist), NULL);
|
||||
sublist = gh_cdr(sublist);
|
||||
|
||||
// FIXME: use a general get tileset function here!
|
||||
i=0;
|
||||
if( strcmp(str,"default") ) {
|
||||
for( ; i<NumTilesets; ++i ) {
|
||||
if( !strcmp(str,Tilesets[i]->Ident) ) {
|
||||
i = 0;
|
||||
if (strcmp(str, "default")) {
|
||||
for (; i < NumTilesets; ++i) {
|
||||
if (!strcmp(str,Tilesets[i]->Ident)) {
|
||||
break;
|
||||
}
|
||||
if( !strcmp(str,Tilesets[i]->Class) ) {
|
||||
if (!strcmp(str,Tilesets[i]->Class)) {
|
||||
break;
|
||||
}
|
||||
}
|
||||
if( i==NumTilesets ) {
|
||||
fprintf(stderr,"Tileset `%s' not available\n",str);
|
||||
errl("tileset not available",gh_car(sublist));
|
||||
if (i == NumTilesets) {
|
||||
fprintf(stderr, "Tileset `%s' not available\n", str);
|
||||
errl("tileset not available", gh_car(sublist));
|
||||
}
|
||||
}
|
||||
tileset=i;
|
||||
tileset = i;
|
||||
free(str);
|
||||
} else if( gh_eq_p(value,gh_symbol2scm("file")) ) {
|
||||
file=gh_scm2newstr(gh_car(sublist),NULL);
|
||||
sublist=gh_cdr(sublist);
|
||||
} else if( gh_eq_p(value,gh_symbol2scm("size")) ) {
|
||||
value=gh_car(sublist);
|
||||
sublist=gh_cdr(sublist);
|
||||
w=gh_scm2int(gh_car(value));
|
||||
value=gh_cdr(value);
|
||||
h=gh_scm2int(gh_car(value));
|
||||
} else if (gh_eq_p(value, gh_symbol2scm("file"))) {
|
||||
file = gh_scm2newstr(gh_car(sublist), NULL);
|
||||
sublist = gh_cdr(sublist);
|
||||
} else if (gh_eq_p(value, gh_symbol2scm("size"))) {
|
||||
value = gh_car(sublist);
|
||||
sublist = gh_cdr(sublist);
|
||||
w = gh_scm2int(gh_car(value));
|
||||
value = gh_cdr(value);
|
||||
h = gh_scm2int(gh_car(value));
|
||||
} else {
|
||||
errl("Unsupported tag",value);
|
||||
errl("Unsupported tag", value);
|
||||
}
|
||||
}
|
||||
if( files ) {
|
||||
if (files) {
|
||||
free(construction->File[tileset].File);
|
||||
construction->File[tileset].File=file;
|
||||
construction->File[tileset].Width=w;
|
||||
construction->File[tileset].Height=h;
|
||||
construction->File[tileset].File = file;
|
||||
construction->File[tileset].Width = w;
|
||||
construction->File[tileset].Height = h;
|
||||
} else {
|
||||
free(construction->ShadowFile[tileset].File);
|
||||
construction->ShadowFile[tileset].File=file;
|
||||
construction->ShadowFile[tileset].Width=w;
|
||||
construction->ShadowFile[tileset].Height=h;
|
||||
construction->ShadowFile[tileset].File = file;
|
||||
construction->ShadowFile[tileset].Width = w;
|
||||
construction->ShadowFile[tileset].Height = h;
|
||||
}
|
||||
} else if( gh_eq_p(value,gh_symbol2scm("constructions")) ) {
|
||||
sublist=gh_car(list);
|
||||
while( !gh_null_p(sublist) ) {
|
||||
} else if (gh_eq_p(value, gh_symbol2scm("constructions"))) {
|
||||
sublist = gh_car(list);
|
||||
while (!gh_null_p(sublist)) {
|
||||
SCM slist;
|
||||
int percent;
|
||||
int file;
|
||||
int frame;
|
||||
ConstructionFrame** cframe;
|
||||
|
||||
percent=0;
|
||||
file=0;
|
||||
frame=0;
|
||||
percent = 0;
|
||||
file = 0;
|
||||
frame = 0;
|
||||
|
||||
slist=gh_car(sublist);
|
||||
sublist=gh_cdr(sublist);
|
||||
while( !gh_null_p(slist) ) {
|
||||
value=gh_car(slist);
|
||||
slist=gh_cdr(slist);
|
||||
slist = gh_car(sublist);
|
||||
sublist = gh_cdr(sublist);
|
||||
while (!gh_null_p(slist)) {
|
||||
value = gh_car(slist);
|
||||
slist = gh_cdr(slist);
|
||||
|
||||
if( gh_eq_p(value,gh_symbol2scm("percent")) ) {
|
||||
percent=gh_scm2int(gh_car(slist));
|
||||
slist=gh_cdr(slist);
|
||||
} else if( gh_eq_p(value,gh_symbol2scm("file")) ) {
|
||||
value=gh_car(slist);
|
||||
if( gh_eq_p(value,gh_symbol2scm("construction")) ) {
|
||||
file=ConstructionFileConstruction;
|
||||
} else if( gh_eq_p(value,gh_symbol2scm("main")) ) {
|
||||
file=ConstructionFileMain;
|
||||
if (gh_eq_p(value, gh_symbol2scm("percent"))) {
|
||||
percent = gh_scm2int(gh_car(slist));
|
||||
slist = gh_cdr(slist);
|
||||
} else if (gh_eq_p(value, gh_symbol2scm("file"))) {
|
||||
value = gh_car(slist);
|
||||
if (gh_eq_p(value, gh_symbol2scm("construction"))) {
|
||||
file = ConstructionFileConstruction;
|
||||
} else if (gh_eq_p(value, gh_symbol2scm("main"))) {
|
||||
file = ConstructionFileMain;
|
||||
} else {
|
||||
errl("Unsupported tag",value);
|
||||
errl("Unsupported tag", value);
|
||||
}
|
||||
slist=gh_cdr(slist);
|
||||
} else if( gh_eq_p(value,gh_symbol2scm("frame")) ) {
|
||||
frame=gh_scm2int(gh_car(slist));
|
||||
slist=gh_cdr(slist);
|
||||
slist = gh_cdr(slist);
|
||||
} else if (gh_eq_p(value, gh_symbol2scm("frame"))) {
|
||||
frame = gh_scm2int(gh_car(slist));
|
||||
slist = gh_cdr(slist);
|
||||
} else {
|
||||
errl("Unsupported tag",value);
|
||||
errl("Unsupported tag", value);
|
||||
}
|
||||
}
|
||||
cframe=&construction->Frames;
|
||||
while( *cframe ) {
|
||||
cframe=&((*cframe)->Next);
|
||||
cframe = &construction->Frames;
|
||||
while (*cframe) {
|
||||
cframe = &((*cframe)->Next);
|
||||
}
|
||||
(*cframe)=malloc(sizeof(ConstructionFrame));
|
||||
(*cframe)->Percent=percent;
|
||||
(*cframe)->File=file;
|
||||
(*cframe)->Frame=frame;
|
||||
(*cframe)->Next=NULL;
|
||||
(*cframe) = malloc(sizeof(ConstructionFrame));
|
||||
(*cframe)->Percent = percent;
|
||||
(*cframe)->File = file;
|
||||
(*cframe)->Frame = frame;
|
||||
(*cframe)->Next = NULL;
|
||||
}
|
||||
} else {
|
||||
// FIXME: this leaves a half initialized construction
|
||||
errl("Unsupported tag",value);
|
||||
errl("Unsupported tag", value);
|
||||
}
|
||||
list=gh_cdr(list);
|
||||
list = gh_cdr(list);
|
||||
}
|
||||
|
||||
return SCM_UNSPECIFIED;
|
||||
|
@ -526,8 +526,8 @@ local SCM CclDefineConstruction(SCM list)
|
|||
global void ConstructionCclRegister(void)
|
||||
{
|
||||
gh_new_procedureN("define-construction-wc-names",
|
||||
CclDefineConstructionWcNames);
|
||||
gh_new_procedureN("define-construction",CclDefineConstruction);
|
||||
CclDefineConstructionWcNames);
|
||||
gh_new_procedureN("define-construction", CclDefineConstruction);
|
||||
|
||||
}
|
||||
//@}
|
||||
|
|
|
@ -10,7 +10,7 @@
|
|||
//
|
||||
/**@name groups.c - The units' groups handling. */
|
||||
//
|
||||
// (c) Copyright 1999-2002 by Patrice Fortier and Lutz Sammer
|
||||
// (c) Copyright 1999-2003 by Patrice Fortier and Lutz Sammer
|
||||
//
|
||||
// This program is free software; you can redistribute it and/or modify
|
||||
// it under the terms of the GNU General Public License as published by
|
||||
|
@ -69,13 +69,13 @@ global void InitGroups(void)
|
|||
{
|
||||
int i;
|
||||
|
||||
for( i=0; i<NUM_GROUPS; i++ ) {
|
||||
for (i = 0; i < NUM_GROUPS; ++i) {
|
||||
int n;
|
||||
|
||||
if( (n=Groups[i].NumUnits) ) { // Cleanup after load
|
||||
while( n-- ) {
|
||||
if ((n = Groups[i].NumUnits)) { // Cleanup after load
|
||||
while (n--) {
|
||||
DebugLevel0Fn("FIXME: old code!\n");
|
||||
Groups[i].Units[n]=UnitSlots[(int)Groups[i].Units[n]];
|
||||
Groups[i].Units[n] = UnitSlots[(int)Groups[i].Units[n]];
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -92,17 +92,17 @@ global void SaveGroups(CLFile* file)
|
|||
int g;
|
||||
char* ref;
|
||||
|
||||
CLprintf(file,"\n;;; -----------------------------------------\n");
|
||||
CLprintf(file,";;; MODULE: groups $Id$\n\n");
|
||||
CLprintf(file, "\n;;; -----------------------------------------\n");
|
||||
CLprintf(file, ";;; MODULE: groups $Id$\n\n");
|
||||
|
||||
for( g=0; g<NUM_GROUPS; g++ ) {
|
||||
CLprintf(file,"(group %d %d '(",g,Groups[g].NumUnits);
|
||||
for( i=0; i<Groups[g].NumUnits; ++i ) {
|
||||
ref=UnitReference(Groups[g].Units[i]);
|
||||
CLprintf(file,"%s ",ref);
|
||||
for (g = 0; g < NUM_GROUPS; ++g) {
|
||||
CLprintf(file, "(group %d %d '(", g, Groups[g].NumUnits);
|
||||
for (i = 0; i < Groups[g].NumUnits; ++i) {
|
||||
ref = UnitReference(Groups[g].Units[i]);
|
||||
CLprintf(file, "%s ", ref);
|
||||
free(ref);
|
||||
}
|
||||
CLprintf(file,"))\n");
|
||||
CLprintf(file, "))\n");
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -113,8 +113,8 @@ global void CleanGroups(void)
|
|||
{
|
||||
int i;
|
||||
|
||||
for( i=0; i<NUM_GROUPS; i++ ) {
|
||||
memset(&Groups[i],0,sizeof(Groups[i]));
|
||||
for (i = 0; i < NUM_GROUPS; ++i) {
|
||||
memset(&Groups[i], 0, sizeof(Groups[i]));
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -150,12 +150,12 @@ global void ClearGroup(int num)
|
|||
UnitGroup *group;
|
||||
int i;
|
||||
|
||||
group=&Groups[num];
|
||||
for( i=0; i<group->NumUnits; i++ ) {
|
||||
group->Units[i]->GroupId &= ~(1<<num);
|
||||
DebugCheck( group->Units[i]->Destroyed );
|
||||
group = &Groups[num];
|
||||
for (i = 0; i < group->NumUnits; ++i) {
|
||||
group->Units[i]->GroupId &= ~(1 << num);
|
||||
DebugCheck(group->Units[i]->Destroyed);
|
||||
}
|
||||
group->NumUnits=0;
|
||||
group->NumUnits = 0;
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -165,17 +165,17 @@ global void ClearGroup(int num)
|
|||
** @param nunits Number of units in array.
|
||||
** @param num Group number for storage.
|
||||
*/
|
||||
global void AddToGroup(Unit **units,int nunits,int num)
|
||||
global void AddToGroup(Unit** units, int nunits, int num)
|
||||
{
|
||||
UnitGroup *group;
|
||||
UnitGroup* group;
|
||||
int i;
|
||||
|
||||
DebugCheck(num>NUM_GROUPS);
|
||||
DebugCheck(num > NUM_GROUPS);
|
||||
|
||||
group=&Groups[num];
|
||||
for( i=0; group->NumUnits<NUM_UNITS_PER_GROUP && i<nunits; i++ ) {
|
||||
group->Units[group->NumUnits++]=units[i];
|
||||
units[i]->GroupId |= (1<<num);
|
||||
group = &Groups[num];
|
||||
for (i = 0; group->NumUnits < NUM_UNITS_PER_GROUP && i < nunits; ++i) {
|
||||
group->Units[group->NumUnits++] = units[i];
|
||||
units[i]->GroupId |= (1 << num);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -186,12 +186,12 @@ global void AddToGroup(Unit **units,int nunits,int num)
|
|||
** @param nunits Number of units in array.
|
||||
** @param num Group number for storage.
|
||||
*/
|
||||
global void SetGroup(Unit **units,int nunits,int num)
|
||||
global void SetGroup(Unit** units, int nunits, int num)
|
||||
{
|
||||
DebugCheck(num>NUM_GROUPS || nunits>NUM_UNITS_PER_GROUP);
|
||||
DebugCheck(num > NUM_GROUPS || nunits > NUM_UNITS_PER_GROUP);
|
||||
|
||||
ClearGroup(num);
|
||||
AddToGroup(units,nunits,num);
|
||||
AddToGroup(units, nunits, num);
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -199,30 +199,30 @@ global void SetGroup(Unit **units,int nunits,int num)
|
|||
**
|
||||
** @param unit Unit to remove from group.
|
||||
*/
|
||||
global void RemoveUnitFromGroups(Unit *unit)
|
||||
global void RemoveUnitFromGroups(Unit* unit)
|
||||
{
|
||||
UnitGroup *group;
|
||||
UnitGroup* group;
|
||||
int num;
|
||||
int i;
|
||||
|
||||
DebugCheck( unit->GroupId==0 ); // unit doesn't belong to a group
|
||||
DebugCheck(unit->GroupId == 0); // unit doesn't belong to a group
|
||||
|
||||
for( num=0; unit->GroupId; num++,unit->GroupId>>=1 ) {
|
||||
if( (unit->GroupId & 1) != 1 ) {
|
||||
for (num = 0; unit->GroupId; ++num, unit->GroupId >>= 1) {
|
||||
if ((unit->GroupId & 1) != 1) {
|
||||
continue;
|
||||
}
|
||||
|
||||
group=&Groups[num];
|
||||
for( i=0; group->Units[i]!=unit; i++ ) {
|
||||
group = &Groups[num];
|
||||
for (i = 0; group->Units[i] != unit; ++i) {
|
||||
;
|
||||
}
|
||||
|
||||
DebugCheck( i>=group->NumUnits ); // oops not found
|
||||
DebugCheck(i >= group->NumUnits); // oops not found
|
||||
|
||||
// This is a clean way that will allow us to add a unit
|
||||
// to a group easily, or make an easy array walk...
|
||||
if( i<--group->NumUnits ) {
|
||||
group->Units[i]=group->Units[group->NumUnits];
|
||||
if (i < --group->NumUnits) {
|
||||
group->Units[i] = group->Units[group->NumUnits];
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -236,21 +236,21 @@ global void RemoveUnitFromGroups(Unit *unit)
|
|||
** @param num Number of units in group
|
||||
** @param units Units in group
|
||||
*/
|
||||
local SCM CclGroup(SCM group,SCM num,SCM units)
|
||||
local SCM CclGroup(SCM group, SCM num, SCM units)
|
||||
{
|
||||
int i;
|
||||
UnitGroup* grp;
|
||||
|
||||
grp=&Groups[gh_scm2int(group)];
|
||||
grp->NumUnits=gh_scm2int(num);
|
||||
i=0;
|
||||
while( !gh_null_p(units) ) {
|
||||
grp = &Groups[gh_scm2int(group)];
|
||||
grp->NumUnits = gh_scm2int(num);
|
||||
i = 0;
|
||||
while (!gh_null_p(units)) {
|
||||
char* str;
|
||||
|
||||
str=gh_scm2newstr(gh_car(units),NULL);
|
||||
grp->Units[i++]=(Unit*)strtol(str+1,NULL,16);
|
||||
str = gh_scm2newstr(gh_car(units), NULL);
|
||||
grp->Units[i++] = (Unit*)strtol(str + 1, NULL, 16);
|
||||
free(str);
|
||||
units=gh_cdr(units);
|
||||
units = gh_cdr(units);
|
||||
}
|
||||
|
||||
return SCM_UNSPECIFIED;
|
||||
|
@ -261,7 +261,7 @@ local SCM CclGroup(SCM group,SCM num,SCM units)
|
|||
*/
|
||||
global void GroupCclRegister(void)
|
||||
{
|
||||
gh_new_procedure3_0("group",CclGroup);
|
||||
gh_new_procedure3_0("group", CclGroup);
|
||||
}
|
||||
|
||||
//@}
|
||||
|
|
|
@ -74,15 +74,15 @@
|
|||
** @param offset Seek position
|
||||
** @param whence How to seek
|
||||
*/
|
||||
local int gzseek(CLFile* file,unsigned offset,int whence)
|
||||
local int gzseek(CLFile* file, unsigned offset, int whence)
|
||||
{
|
||||
char buf[32];
|
||||
|
||||
while( offset>sizeof(buf) ) {
|
||||
gzread(file,buf,sizeof(buf));
|
||||
offset-=sizeof(buf);
|
||||
while (offset > sizeof(buf)) {
|
||||
gzread(file, buf, sizeof(buf));
|
||||
offset -= sizeof(buf);
|
||||
}
|
||||
return gzread(file,buf,offset);
|
||||
return gzread(file, buf, offset);
|
||||
}
|
||||
|
||||
#endif // } ZLIB_VERSION<="1.0.4"
|
||||
|
@ -106,43 +106,19 @@ local int gzseek(CLFile* file,unsigned offset,int whence)
|
|||
** @param offset Seek position
|
||||
** @param whence How to seek
|
||||
*/
|
||||
local void bzseek(BZFILE* file,unsigned offset,int whence __attribute__((unused)))
|
||||
local void bzseek(BZFILE* file, unsigned offset, int whence __attribute__((unused)))
|
||||
{
|
||||
char buf[32];
|
||||
|
||||
while( offset>sizeof(buf) ) {
|
||||
bzread(file,buf,sizeof(buf));
|
||||
offset-=sizeof(buf);
|
||||
while (offset > sizeof(buf)) {
|
||||
bzread(file, buf, sizeof(buf));
|
||||
offset -= sizeof(buf);
|
||||
}
|
||||
bzread(file,buf,offset);
|
||||
bzread(file, buf, offset);
|
||||
}
|
||||
|
||||
#endif // USE_BZ2LIB
|
||||
|
||||
#ifdef USE_ZZIPLIB
|
||||
|
||||
#if 0
|
||||
/**
|
||||
** Seek on compressed input. (I hope newer libs support it directly)
|
||||
**
|
||||
** @param file File handle
|
||||
** @param offset Seek position
|
||||
** @param whence How to seek
|
||||
*/
|
||||
local void zzip_seek(ZZIP_FILE* file,unsigned offset,int whence __attribute__((unused)))
|
||||
{
|
||||
char buf[32];
|
||||
|
||||
while( offset>sizeof(buf) ) {
|
||||
zzip_read(file,buf,sizeof(buf));
|
||||
offset-=sizeof(buf);
|
||||
}
|
||||
zzip_read(file,buf,offset);
|
||||
}
|
||||
#endif
|
||||
|
||||
#endif // USE_ZZIPLIB
|
||||
|
||||
#if defined(USE_ZLIB) || defined(USE_BZ2LIB) || defined(USE_ZZIPLIB)
|
||||
|
||||
/**
|
||||
|
@ -153,17 +129,18 @@ local void zzip_seek(ZZIP_FILE* file,unsigned offset,int whence __attribute__((u
|
|||
**
|
||||
** @return File Pointer
|
||||
*/
|
||||
global CLFile *CLopen(const char *fn,long openflags)
|
||||
global CLFile* CLopen(const char* fn, long openflags)
|
||||
{
|
||||
CLFile clf;
|
||||
CLFile *result;
|
||||
CLFile* result;
|
||||
char buf[512];
|
||||
char openstring[5];
|
||||
if ( (openflags&CL_OPEN_READ) && (openflags&CL_OPEN_WRITE) ) {
|
||||
strcpy(openstring,"rwb");
|
||||
} else if (openflags&CL_OPEN_READ) {
|
||||
strcpy(openstring,"rb");
|
||||
} else if (openflags&CL_OPEN_WRITE) {
|
||||
|
||||
if ((openflags & CL_OPEN_READ) && (openflags & CL_OPEN_WRITE)) {
|
||||
strcpy(openstring, "rwb");
|
||||
} else if (openflags &CL_OPEN_READ) {
|
||||
strcpy(openstring, "rb");
|
||||
} else if (openflags & CL_OPEN_WRITE) {
|
||||
strcpy(openstring,"wb");
|
||||
} else {
|
||||
DebugLevel0("Bad CLopen flags");
|
||||
|
@ -173,36 +150,36 @@ global CLFile *CLopen(const char *fn,long openflags)
|
|||
|
||||
clf.cl_type = CLF_TYPE_INVALID;
|
||||
|
||||
if (openflags&CL_OPEN_WRITE) {
|
||||
if (openflags & CL_OPEN_WRITE) {
|
||||
#ifdef USE_BZ2LIB
|
||||
if ( (openflags&CL_WRITE_BZ2) &&
|
||||
( clf.cl_bz = bzopen(strcat(strcpy(buf,fn),".bz2"), openstring)) ) {
|
||||
if ((openflags & CL_WRITE_BZ2) &&
|
||||
(clf.cl_bz = bzopen(strcat(strcpy(buf, fn), ".bz2"), openstring))) {
|
||||
clf.cl_type = CLF_TYPE_BZIP2;
|
||||
} else
|
||||
#endif
|
||||
#ifdef USE_ZLIB
|
||||
if ( (openflags&CL_WRITE_GZ) &&
|
||||
( clf.cl_gz = gzopen(strcat(strcpy(buf,fn),".gz"), openstring)) ) {
|
||||
clf.cl_type = CLF_TYPE_GZIP;
|
||||
if ((openflags & CL_WRITE_GZ) &&
|
||||
(clf.cl_gz = gzopen(strcat(strcpy(buf, fn), ".gz"), openstring))) {
|
||||
clf.cl_type = CLF_TYPE_GZIP;
|
||||
} else
|
||||
#endif
|
||||
if ((clf.cl_plain = fopen(fn,openstring))) {
|
||||
if ((clf.cl_plain = fopen(fn, openstring))) {
|
||||
clf.cl_type = CLF_TYPE_PLAIN;
|
||||
}
|
||||
} else {
|
||||
if (!(clf.cl_plain = fopen(fn, openstring))) { // try plain first
|
||||
#ifdef USE_ZLIB
|
||||
if ((clf.cl_gz = gzopen(strcat(strcpy(buf,fn),".gz"), "rb"))) {
|
||||
if ((clf.cl_gz = gzopen(strcat(strcpy(buf, fn), ".gz"), "rb"))) {
|
||||
clf.cl_type = CLF_TYPE_GZIP;
|
||||
} else
|
||||
#endif
|
||||
#ifdef USE_BZ2LIB
|
||||
if ((clf.cl_bz = bzopen(strcat(strcpy(buf,fn),".bz2"), "rb"))) {
|
||||
if ((clf.cl_bz = bzopen(strcat(strcpy(buf, fn), ".bz2"), "rb"))) {
|
||||
clf.cl_type = CLF_TYPE_BZIP2;
|
||||
} else
|
||||
#endif
|
||||
#ifdef USE_ZZIPLIB
|
||||
if ((clf.cl_zz = zzip_open(strcpy(buf,fn),O_RDONLY|O_BINARY) )) {
|
||||
if ((clf.cl_zz = zzip_open(strcpy(buf, fn), O_RDONLY | O_BINARY))) {
|
||||
clf.cl_type = CLF_TYPE_ZZIP;
|
||||
} else
|
||||
#endif
|
||||
|
@ -244,12 +221,12 @@ global CLFile *CLopen(const char *fn,long openflags)
|
|||
}
|
||||
|
||||
if (clf.cl_type == CLF_TYPE_INVALID) {
|
||||
//fprintf(stderr,"%s in ", buf);
|
||||
//fprintf(stderr, "%s in ", buf);
|
||||
return NULL;
|
||||
}
|
||||
|
||||
// ok, here we go
|
||||
result = (CLFile *)malloc(sizeof(CLFile));
|
||||
result = (CLFile*)malloc(sizeof(CLFile));
|
||||
if (result) {
|
||||
*result = clf;
|
||||
}
|
||||
|
@ -261,7 +238,7 @@ global CLFile *CLopen(const char *fn,long openflags)
|
|||
**
|
||||
** @param file CLFile pointer.
|
||||
*/
|
||||
global int CLclose(CLFile *file)
|
||||
global int CLclose(CLFile* file)
|
||||
{
|
||||
int tp;
|
||||
int ret;
|
||||
|
@ -303,7 +280,7 @@ global int CLclose(CLFile *file)
|
|||
** @param buf Pointer to read the data to.
|
||||
** @param len number of bytes to read.
|
||||
*/
|
||||
global int CLread(CLFile *file, void *buf, size_t len)
|
||||
global int CLread(CLFile* file, void* buf, size_t len)
|
||||
{
|
||||
int tp;
|
||||
int ret;
|
||||
|
@ -342,24 +319,24 @@ global int CLread(CLFile *file, void *buf, size_t len)
|
|||
** @param format String Format.
|
||||
** @param ... Parameter List.
|
||||
*/
|
||||
global int CLprintf(CLFile *file, char *format, ...)
|
||||
global int CLprintf(CLFile* file, char* format, ...)
|
||||
{
|
||||
int n;
|
||||
int size;
|
||||
int ret;
|
||||
int tp;
|
||||
char *p;
|
||||
char* p;
|
||||
va_list ap;
|
||||
|
||||
size=100;
|
||||
ret=-1;
|
||||
if ((p = malloc (size)) == NULL) {
|
||||
size = 100;
|
||||
ret = -1;
|
||||
if ((p = malloc(size)) == NULL) {
|
||||
return -1;
|
||||
}
|
||||
while (1) {
|
||||
/* Try to print in the allocated space. */
|
||||
va_start(ap, format);
|
||||
n = vsnprintf (p, size, format, ap);
|
||||
n = vsnprintf(p, size, format, ap);
|
||||
va_end(ap);
|
||||
/* If that worked, string was processed. */
|
||||
if (n > -1 && n < size) {
|
||||
|
@ -367,11 +344,11 @@ global int CLprintf(CLFile *file, char *format, ...)
|
|||
}
|
||||
/* Else try again with more space. */
|
||||
if (n > -1) { /* glibc 2.1 */
|
||||
size = n+1; /* precisely what is needed */
|
||||
size = n + 1; /* precisely what is needed */
|
||||
} else { /* glibc 2.0 */
|
||||
size *= 2; /* twice the old size */
|
||||
}
|
||||
if ((p = realloc (p, size)) == NULL) {
|
||||
if ((p = realloc(p, size)) == NULL) {
|
||||
return -1;
|
||||
}
|
||||
}
|
||||
|
@ -381,7 +358,7 @@ global int CLprintf(CLFile *file, char *format, ...)
|
|||
|
||||
if (file && (tp = file->cl_type) != CLF_TYPE_INVALID) {
|
||||
if (tp == CLF_TYPE_PLAIN) {
|
||||
ret = fwrite(p,size,1,file->cl_plain);
|
||||
ret = fwrite(p, size, 1, file->cl_plain);
|
||||
}
|
||||
#ifdef USE_ZLIB
|
||||
if (tp == CLF_TYPE_GZIP) {
|
||||
|
@ -414,7 +391,7 @@ global int CLprintf(CLFile *file, char *format, ...)
|
|||
** @param offset Seek position
|
||||
** @param whence How to seek
|
||||
*/
|
||||
global int CLseek(CLFile *file, long offset, int whence)
|
||||
global int CLseek(CLFile* file, long offset, int whence)
|
||||
{
|
||||
int tp;
|
||||
int ret;
|
||||
|
@ -461,7 +438,7 @@ global int CLseek(CLFile *file, long offset, int whence)
|
|||
**
|
||||
** @return Pointer to buffer.
|
||||
*/
|
||||
global char* LibraryFileName(const char* file,char* buffer)
|
||||
global char* LibraryFileName(const char* file, char* buffer)
|
||||
{
|
||||
#ifdef USE_ZZIPLIB
|
||||
ZZIP_FILE* zp;
|
||||
|
@ -471,25 +448,25 @@ global char* LibraryFileName(const char* file,char* buffer)
|
|||
//
|
||||
// Absolute path or in current directory.
|
||||
//
|
||||
strcpy(buffer,file);
|
||||
if( *buffer=='/' || !access(buffer,R_OK) ) {
|
||||
strcpy(buffer, file);
|
||||
if (*buffer == '/' || !access(buffer, R_OK)) {
|
||||
return buffer;
|
||||
}
|
||||
#ifdef USE_ZLIB // gzip or bzip2 in current directory
|
||||
sprintf(buffer,"%s.gz",file);
|
||||
if( !access(buffer,R_OK) ) {
|
||||
sprintf(buffer, "%s.gz", file);
|
||||
if (!access(buffer, R_OK)) {
|
||||
return buffer;
|
||||
}
|
||||
#endif
|
||||
#ifdef USE_BZ2LIB
|
||||
sprintf(buffer,"%s.bz2",file);
|
||||
if( !access(buffer,R_OK) ) {
|
||||
sprintf(buffer, "%s.bz2", file);
|
||||
if (!access(buffer, R_OK)) {
|
||||
return buffer;
|
||||
}
|
||||
#endif
|
||||
#ifdef USE_ZZIPLIB
|
||||
strcpy(buffer,file);
|
||||
if( (zp=zzip_open(buffer,O_RDONLY|O_BINARY)) ) {
|
||||
strcpy(buffer, file);
|
||||
if ((zp = zzip_open(buffer, O_RDONLY | O_BINARY))) {
|
||||
zzip_close(zp);
|
||||
return buffer;
|
||||
}
|
||||
|
@ -498,74 +475,74 @@ global char* LibraryFileName(const char* file,char* buffer)
|
|||
//
|
||||
// Try in map directory
|
||||
//
|
||||
if( *CurrentMapPath ) {
|
||||
if (*CurrentMapPath) {
|
||||
DebugLevel3Fn("Map path: %s\n" _C_ CurrentMapPath);
|
||||
if( *CurrentMapPath=='.' || *CurrentMapPath=='/' ) {
|
||||
strcpy(buffer,CurrentMapPath);
|
||||
if( (s=strrchr(buffer,'/')) ) {
|
||||
s[1]='\0';
|
||||
if (*CurrentMapPath == '.' || *CurrentMapPath == '/') {
|
||||
strcpy(buffer, CurrentMapPath);
|
||||
if ((s = strrchr(buffer, '/'))) {
|
||||
s[1] = '\0';
|
||||
}
|
||||
strcat(buffer,file);
|
||||
strcat(buffer, file);
|
||||
} else {
|
||||
strcpy(buffer,StratagusLibPath);
|
||||
if( *buffer ) {
|
||||
strcat(buffer,"/");
|
||||
strcpy(buffer, StratagusLibPath);
|
||||
if (*buffer) {
|
||||
strcat(buffer, "/");
|
||||
}
|
||||
strcat(buffer,CurrentMapPath);
|
||||
if( (s=strrchr(buffer,'/')) ) {
|
||||
s[1]='\0';
|
||||
strcat(buffer, CurrentMapPath);
|
||||
if ((s = strrchr(buffer, '/'))) {
|
||||
s[1] = '\0';
|
||||
}
|
||||
strcat(buffer,file);
|
||||
strcat(buffer, file);
|
||||
}
|
||||
if( !access(buffer,R_OK) ) {
|
||||
if (!access(buffer, R_OK)) {
|
||||
return buffer;
|
||||
}
|
||||
|
||||
#ifdef USE_ZLIB // gzip or bzip2 in map directory directory
|
||||
strcat(buffer,".gz");
|
||||
if( !access(buffer,R_OK) ) {
|
||||
strcat(buffer, ".gz");
|
||||
if (!access(buffer, R_OK)) {
|
||||
return buffer;
|
||||
}
|
||||
*strrchr(buffer,'.')='\0';
|
||||
*strrchr(buffer, '.') = '\0';
|
||||
#endif
|
||||
#ifdef USE_BZ2LIB
|
||||
strcat(buffer,".bz2");
|
||||
if( !access(buffer,R_OK) ) {
|
||||
strcat(buffer, ".bz2");
|
||||
if (!access(buffer, R_OK)) {
|
||||
return buffer;
|
||||
}
|
||||
*strrchr(buffer,'.')='\0';
|
||||
*strrchr(buffer, '.') = '\0';
|
||||
#endif
|
||||
#ifdef USE_ZZIPLIB
|
||||
if( (zp=zzip_open(buffer,O_RDONLY|O_BINARY)) ) {
|
||||
if ((zp = zzip_open(buffer, O_RDONLY | O_BINARY))) {
|
||||
zzip_close(zp);
|
||||
return buffer;
|
||||
}
|
||||
#endif // USE_ZZIPLIB
|
||||
}
|
||||
|
||||
if( (s = getenv("HOME")) ) {
|
||||
if ((s = getenv("HOME"))) {
|
||||
//
|
||||
// In user home directory
|
||||
//
|
||||
sprintf(buffer,"%s/%s/%s/%s",s,STRATAGUS_HOME_PATH,GameName,file);
|
||||
if( !access(buffer,R_OK) ) {
|
||||
sprintf(buffer, "%s/%s/%s/%s", s, STRATAGUS_HOME_PATH, GameName, file);
|
||||
if (!access(buffer,R_OK)) {
|
||||
return buffer;
|
||||
}
|
||||
#ifdef USE_ZLIB // gzip or bzip2 in user home directory
|
||||
sprintf(buffer,"%s/%s/%s/%s.gz",s,STRATAGUS_HOME_PATH,GameName,file);
|
||||
if( !access(buffer,R_OK) ) {
|
||||
sprintf(buffer, "%s/%s/%s/%s.gz", s, STRATAGUS_HOME_PATH, GameName, file);
|
||||
if (!access(buffer, R_OK)) {
|
||||
return buffer;
|
||||
}
|
||||
#endif
|
||||
#ifdef USE_BZ2LIB
|
||||
sprintf(buffer,"%s/%s/%s/%s.bz2",s,STRATAGUS_HOME_PATH,GameName,file);
|
||||
if( !access(buffer,R_OK) ) {
|
||||
sprintf(buffer, "%s/%s/%s/%s.bz2", s, STRATAGUS_HOME_PATH, GameName, file);
|
||||
if (!access(buffer, R_OK)) {
|
||||
return buffer;
|
||||
}
|
||||
#endif
|
||||
#ifdef USE_ZZIPLIB
|
||||
sprintf(buffer,"%s/%s/%s/%s",s,STRATAGUS_HOME_PATH,GameName,file);
|
||||
if( (zp=zzip_open(buffer,O_RDONLY|O_BINARY)) ) {
|
||||
sprintf(buffer, "%s/%s/%s/%s", s, STRATAGUS_HOME_PATH, GameName, file);
|
||||
if ((zp = zzip_open(buffer, O_RDONLY | O_BINARY))) {
|
||||
zzip_close(zp);
|
||||
return buffer;
|
||||
}
|
||||
|
@ -575,32 +552,32 @@ global char* LibraryFileName(const char* file,char* buffer)
|
|||
//
|
||||
// In global shared directory
|
||||
//
|
||||
sprintf(buffer,"%s/%s",StratagusLibPath,file);
|
||||
if( !access(buffer,R_OK) ) {
|
||||
sprintf(buffer, "%s/%s", StratagusLibPath, file);
|
||||
if (!access(buffer, R_OK)) {
|
||||
return buffer;
|
||||
}
|
||||
#ifdef USE_ZLIB // gzip or bzip2 in global shared directory
|
||||
sprintf(buffer,"%s/%s.gz",StratagusLibPath,file);
|
||||
if( !access(buffer,R_OK) ) {
|
||||
sprintf(buffer, "%s/%s.gz", StratagusLibPath, file);
|
||||
if (!access(buffer, R_OK)) {
|
||||
return buffer;
|
||||
}
|
||||
#endif
|
||||
#ifdef USE_BZ2LIB
|
||||
sprintf(buffer,"%s/%s.bz2",StratagusLibPath,file);
|
||||
if( !access(buffer,R_OK) ) {
|
||||
sprintf(buffer, "%s/%s.bz2", StratagusLibPath, file);
|
||||
if (!access(buffer, R_OK)) {
|
||||
return buffer;
|
||||
}
|
||||
#endif
|
||||
#ifdef USE_ZZIPLIB
|
||||
sprintf(buffer,"%s/%s",StratagusLibPath,file);
|
||||
if( (zp=zzip_open(buffer,O_RDONLY|O_BINARY)) ) {
|
||||
sprintf(buffer, "%s/%s", StratagusLibPath, file);
|
||||
if ((zp = zzip_open(buffer, O_RDONLY | O_BINARY))) {
|
||||
zzip_close(zp);
|
||||
return buffer;
|
||||
}
|
||||
#endif // USE_ZZIPLIB
|
||||
DebugLevel0Fn("File `%s' not found\n" _C_ file);
|
||||
|
||||
strcpy(buffer,file);
|
||||
strcpy(buffer, file);
|
||||
return buffer;
|
||||
}
|
||||
|
||||
|
@ -612,10 +589,10 @@ global char* LibraryFileName(const char* file,char* buffer)
|
|||
**
|
||||
** @return v1-v2
|
||||
*/
|
||||
local int flqcmp(const void *v1, const void *v2)
|
||||
local int flqcmp(const void* v1, const void* v2)
|
||||
{
|
||||
const FileList *c1;
|
||||
const FileList *c2;
|
||||
const FileList* c1;
|
||||
const FileList* c2;
|
||||
|
||||
c1 = v1;
|
||||
c2 = v2;
|
||||
|
@ -654,18 +631,18 @@ __my_zzip_open_zip(const char* filename, int filemode)
|
|||
fd = -1;
|
||||
len = strlen(filename);
|
||||
#ifdef USE_WIN32
|
||||
if (len+4 < PATH_MAX) {
|
||||
if (len + 4 < PATH_MAX) {
|
||||
strcpy(file, filename);
|
||||
strcpy(file+len, ".zip");
|
||||
strcpy(file + len, ".zip");
|
||||
fd = open(file, filemode);
|
||||
}
|
||||
#else
|
||||
ext = my_zzip_default_fileext;
|
||||
if (len+4 < PATH_MAX) {
|
||||
memcpy(file, filename, len+1);
|
||||
if (len + 4 < PATH_MAX) {
|
||||
memcpy(file, filename, len + 1);
|
||||
|
||||
for ( ; *ext ; ++ext) {
|
||||
strcpy (file+len, *ext);
|
||||
for (; *ext ; ++ext) {
|
||||
strcpy(file + len, *ext);
|
||||
fd = open(file, filemode);
|
||||
if (fd != -1) {
|
||||
break;
|
||||
|
@ -686,11 +663,11 @@ __my_zzip_open_zip(const char* filename, int filemode)
|
|||
**
|
||||
** @return Pointer to FileList struct describing Files found.
|
||||
*/
|
||||
global int ReadDataDirectory(const char* dirname,int (*filter)(char*,FileList *),FileList **flp)
|
||||
global int ReadDataDirectory(const char* dirname, int (*filter)(char*, FileList*), FileList** flp)
|
||||
{
|
||||
#ifdef USE_ZZIPLIB
|
||||
ZZIP_DIR *dirp = NULL;
|
||||
ZZIP_DIRENT *dp;
|
||||
ZZIP_DIR* dirp = NULL;
|
||||
ZZIP_DIRENT* dp;
|
||||
// ATTENTION: valid until end of file!
|
||||
#define readdir zzip_readdir
|
||||
#define closedir zzip_closedir
|
||||
|
@ -698,11 +675,11 @@ global int ReadDataDirectory(const char* dirname,int (*filter)(char*,FileList *)
|
|||
int entvalid;
|
||||
char zzbasepath[PATH_MAX];
|
||||
struct stat st;
|
||||
char *cp;
|
||||
char* cp;
|
||||
#else
|
||||
#ifndef _MSC_VER
|
||||
DIR *dirp;
|
||||
struct dirent *dp;
|
||||
DIR* dirp;
|
||||
struct dirent* dp;
|
||||
#endif
|
||||
struct stat st;
|
||||
#endif
|
||||
|
@ -710,13 +687,13 @@ global int ReadDataDirectory(const char* dirname,int (*filter)(char*,FileList *)
|
|||
struct _finddata_t fileinfo;
|
||||
long hFile;
|
||||
#endif
|
||||
FileList *nfl;
|
||||
FileList *fl = NULL;
|
||||
FileList* nfl;
|
||||
FileList* fl = NULL;
|
||||
int n;
|
||||
int isdir = 0; // silence gcc..
|
||||
char *np;
|
||||
char* np;
|
||||
char buffer[PATH_MAX];
|
||||
char *filename;
|
||||
char* filename;
|
||||
|
||||
strcpy(buffer, dirname);
|
||||
n = strlen(buffer);
|
||||
|
@ -728,15 +705,14 @@ global int ReadDataDirectory(const char* dirname,int (*filter)(char*,FileList *)
|
|||
n = 0;
|
||||
|
||||
#ifdef USE_ZZIPLIB
|
||||
strcpy (zzbasepath, dirname);
|
||||
strcpy(zzbasepath, dirname);
|
||||
/* per each slash in filename, check if it there is a zzip around */
|
||||
while ((cp = strrchr(zzbasepath, '/')))
|
||||
{
|
||||
while ((cp = strrchr(zzbasepath, '/'))) {
|
||||
int fd;
|
||||
zzip_error_t e;
|
||||
|
||||
*cp = '\0'; /* cut at path separator == possible zipfile basename */
|
||||
fd = __my_zzip_open_zip(zzbasepath, O_RDONLY|O_BINARY);
|
||||
fd = __my_zzip_open_zip(zzbasepath, O_RDONLY | O_BINARY);
|
||||
if (fd != -1) {
|
||||
/* found zip-file, now open it */
|
||||
dirp = zzip_dir_fdopen(fd, &e);
|
||||
|
@ -757,7 +733,7 @@ global int ReadDataDirectory(const char* dirname,int (*filter)(char*,FileList *)
|
|||
// and we want it vice versa in this special case. Otherwise it would not
|
||||
// match the path separator backtrace above, which relies on recursive
|
||||
// __zip_open_dir(). __zip_open_dir() only detects zipfiles, not real dirs!
|
||||
fd = __my_zzip_open_zip(dirname, O_RDONLY|O_BINARY);
|
||||
fd = __my_zzip_open_zip(dirname, O_RDONLY | O_BINARY);
|
||||
if (fd == -1) {
|
||||
dirp = zzip_opendir(dirname);
|
||||
zzbasepath[0] = 0;
|
||||
|
@ -768,14 +744,16 @@ global int ReadDataDirectory(const char* dirname,int (*filter)(char*,FileList *)
|
|||
close(fd);
|
||||
dirp = NULL;
|
||||
} else {
|
||||
strcpy (zzbasepath, dirname);
|
||||
strcpy(zzbasepath, dirname);
|
||||
}
|
||||
DebugLevel3Fn("zzbasepath `%s', dirname `%s'\n"
|
||||
_C_ zzbasepath _C_ dirname);
|
||||
DebugLevel3Fn("zzbasepath `%s', dirname `%s'\n" _C_
|
||||
zzbasepath _C_ dirname);
|
||||
}
|
||||
}
|
||||
#ifndef _MSC_VER
|
||||
IfDebug(if (!dirp) { DebugLevel0Fn("Dir `%s' not found\n" _C_ dirname); });
|
||||
#if !defined(_MSC_VER) && defined(DEBUG)
|
||||
if (!dirp) {
|
||||
DebugLevel0Fn("Dir `%s' not found\n" _C_ dirname);
|
||||
}
|
||||
#endif
|
||||
#else
|
||||
#ifndef _MSC_VER
|
||||
|
@ -821,10 +799,12 @@ global int ReadDataDirectory(const char* dirname,int (*filter)(char*,FileList *)
|
|||
#endif
|
||||
#endif
|
||||
|
||||
if (strcmp(filename, ".") == 0)
|
||||
if (strcmp(filename, ".") == 0) {
|
||||
continue;
|
||||
if (strcmp(filename, "..") == 0)
|
||||
}
|
||||
if (strcmp(filename, "..") == 0) {
|
||||
continue;
|
||||
}
|
||||
|
||||
strcpy(np, filename);
|
||||
#ifdef USE_ZZIPLIB
|
||||
|
@ -856,10 +836,10 @@ global int ReadDataDirectory(const char* dirname,int (*filter)(char*,FileList *)
|
|||
len = strlen(zzbasepath);
|
||||
isdir = 0;
|
||||
if (strlen(dirname) > len) {
|
||||
cp = (char *)dirname + len + 1;
|
||||
cp = (char*)dirname + len + 1;
|
||||
len = strlen(cp);
|
||||
if (strlen(filename) >= len && memcmp(filename, cp, len) == 0 &&
|
||||
filename[len] == '/' && filename[len + 1]) {
|
||||
filename[len] == '/' && filename[len + 1]) {
|
||||
strcpy(np, filename + len + 1);
|
||||
goto zzentry;
|
||||
}
|
||||
|
@ -875,7 +855,7 @@ zzentry:
|
|||
if (cp) {
|
||||
isdir = 1;
|
||||
*cp = 0;
|
||||
for (i = 0; i < n; i++) {
|
||||
for (i = 0; i < n; ++i) {
|
||||
if (fl[i].type == 0 && strcmp(fl[i].name, np) == 0) {
|
||||
entvalid = 0; // already there
|
||||
break;
|
||||
|
@ -932,7 +912,7 @@ zzentry:
|
|||
}
|
||||
}
|
||||
}
|
||||
n++;
|
||||
++n;
|
||||
}
|
||||
}
|
||||
#ifndef _MSC_VER
|
||||
|
@ -955,7 +935,7 @@ zzentry:
|
|||
if (n == 0) {
|
||||
fl = NULL;
|
||||
} else {
|
||||
qsort((char *)fl, n, sizeof(FileList), flqcmp);
|
||||
qsort((char*)fl, n, sizeof(FileList), flqcmp);
|
||||
}
|
||||
*flp = fl;
|
||||
return n;
|
||||
|
|
|
@ -147,7 +147,7 @@ global void LoadMissileSprites(void)
|
|||
|
||||
buf = alloca(strlen(file) + 9 + 1);
|
||||
file = strcat(strcpy(buf, "graphics/"), file);
|
||||
ShowLoadProgress("\tMissile %s\n", file);
|
||||
ShowLoadProgress("Missile %s", file);
|
||||
MissileTypes[i].Sprite = LoadSprite(
|
||||
file, MissileTypes[i].Width, MissileTypes[i].Height);
|
||||
|
||||
|
|
File diff suppressed because it is too large
Load diff
|
@ -210,7 +210,7 @@ global void LoadIcons(void)
|
|||
file = icon->File->FileName;
|
||||
buf = alloca(strlen(file) + 9 + 1);
|
||||
file = strcat(strcpy(buf, "graphics/"), file);
|
||||
ShowLoadProgress("\tIcons %s\n", file);
|
||||
ShowLoadProgress("Icons %s", file);
|
||||
icon->File->Sprite = LoadSprite(file,IconWidth,IconHeight);
|
||||
#ifdef USE_OPENGL
|
||||
MakeTexture(icon->File->Sprite, icon->File->Sprite->Width,
|
||||
|
|
File diff suppressed because it is too large
Load diff
|
@ -1315,7 +1315,7 @@ global void LoadUnitTypes(void)
|
|||
type = UnitTypes[i];
|
||||
if ((file = type->ShadowFile)) {
|
||||
file = strcat(strcpy(buf, "graphics/"), file);
|
||||
ShowLoadProgress("\tUnit `%s'\n", file);
|
||||
ShowLoadProgress("Unit `%s'", file);
|
||||
type->ShadowSprite = LoadSprite(file, type->ShadowWidth,
|
||||
type->ShadowHeight);
|
||||
}
|
||||
|
@ -1326,13 +1326,13 @@ global void LoadUnitTypes(void)
|
|||
if ((resinfo = type->ResInfo[res])) {
|
||||
if ((file = resinfo->FileWhenLoaded)) {
|
||||
file = strcat(strcpy(buf, "graphics/"), file);
|
||||
ShowLoadProgress("\tUnit `%s'\n", file);
|
||||
ShowLoadProgress("Unit `%s'", file);
|
||||
resinfo->SpriteWhenLoaded = LoadSprite(file, type->Width,
|
||||
type->Height);
|
||||
}
|
||||
if ((file = resinfo->FileWhenEmpty)) {
|
||||
file = strcat(strcpy(buf, "graphics/"), file);
|
||||
ShowLoadProgress("\tUnit `%s'\n", file);
|
||||
ShowLoadProgress("Unit `%s'", file);
|
||||
resinfo->SpriteWhenEmpty = LoadSprite(file, type->Width,
|
||||
type->Height);
|
||||
}
|
||||
|
@ -1360,7 +1360,7 @@ global void LoadUnitTypes(void)
|
|||
|
||||
buf = alloca(strlen(file) + 9 + 1);
|
||||
file = strcat(strcpy(buf, "graphics/"), file);
|
||||
ShowLoadProgress("\tUnit `%s'\n", file);
|
||||
ShowLoadProgress("Unit `%s'", file);
|
||||
type->Sprite = LoadSprite(file, type->Width, type->Height);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -228,7 +228,7 @@ global void LoadCursors(const char* race)
|
|||
|
||||
buf = alloca(strlen(file) + 9 + 1);
|
||||
file = strcat(strcpy(buf,"graphics/"), file);
|
||||
ShowLoadProgress("\tCursor %s\n", file);
|
||||
ShowLoadProgress("Cursor %s", file);
|
||||
Cursors[i].Sprite = LoadSprite(file,
|
||||
Cursors[i].Width, Cursors[i].Height);
|
||||
}
|
||||
|
@ -680,7 +680,8 @@ local void DrawCursor(const CursorType* type, int x, int y, int frame)
|
|||
|
||||
//Save (seen) area behind sprite
|
||||
CLIP_RECTANGLE(x, y, w, h);
|
||||
SaveCursorBackground(OldCursorX = x, OldCursorY = y, OldCursorW = w, OldCursorH = h);
|
||||
SaveCursorBackground(OldCursorX = x, OldCursorY = y,
|
||||
OldCursorW = w, OldCursorH = h);
|
||||
|
||||
//Draw sprite (using its own clipping) FIXME: prevent clipping twice
|
||||
VideoDrawClip(type->Sprite, frame, spritex, spritey);
|
||||
|
|
|
@ -871,7 +871,7 @@ global void LoadFonts(void)
|
|||
|
||||
for (i = 0; i<sizeof(Fonts) / sizeof(*Fonts); ++i) {
|
||||
if (Fonts[i].File) {
|
||||
ShowLoadProgress("\tFonts %s\n", Fonts[i].File);
|
||||
ShowLoadProgress("Fonts %s", Fonts[i].File);
|
||||
Fonts[i].Graphic = LoadGraphic(Fonts[i].File);
|
||||
FontMeasureWidths(Fonts + i);
|
||||
#ifdef USE_OPENGL
|
||||
|
@ -964,7 +964,7 @@ local SCM CclDefineFont(SCM type, SCM file, SCM width, SCM height)
|
|||
i = CclFontByIdentifier(type);
|
||||
free(Fonts[i].File);
|
||||
VideoSaveFree(Fonts[i].Graphic);
|
||||
Fonts[i].Graphic=NULL;
|
||||
Fonts[i].Graphic = NULL;
|
||||
Fonts[i].File = gh_scm2newstr(file, NULL);
|
||||
Fonts[i].Width = gh_scm2int(width);
|
||||
Fonts[i].Height = gh_scm2int(height);
|
||||
|
|
Loading…
Add table
Reference in a new issue