Created
April 22, 2020 11:52
-
-
Save siredmar/af177c37f92e91f56f06e90ecbb039ca to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/*========================================+ | |
I Insel-Daten einlesen und konvertieren I | |
+=========================================*/ | |
void ReadIsoInselHaus(char *name, void *mem, long lengh) | |
{ | |
int i; | |
int sizex, sizey; | |
int saveanz; | |
TISOINSEL *aktinsel; | |
TISOHAUS *akthaus; | |
TISOSAVE *aktsave; | |
/*---Aktuelles Insel-Format---*/ | |
if (strcmp(name, "INSELHAUS") == 0) | |
{ | |
aktsave = mem; | |
saveanz = lengh/sizeof(TISOSAVE); | |
for (i = 0; i < saveanz; i++) | |
{ | |
if ((akthaus = GetIsoHaus(20000+aktsave[i].id)) != NULL) | |
if (iso_load_insel != NULL) | |
aktinsel = iso_load_insel; | |
else if (iso_noclear) | |
aktinsel = iso_bau_insel; | |
else aktinsel = &iso_insel[aktsave[i].inselnr]; | |
switch (aktsave[i].ausricht) | |
{ | |
case 0: | |
case 2: | |
sizex = akthaus->sizex; | |
sizey = akthaus->sizey; | |
break; | |
case 1: | |
case 3: | |
sizex = akthaus->sizey; | |
sizey = akthaus->sizex; | |
break; | |
} | |
if ((aktsave[i].posx >= 0)&&(aktsave[i].posx+sizex <= | |
aktinsel->felderx) | |
&& (aktsave[i].posy >= 0)&&(aktsave[i].posy+sizey <= | |
aktinsel->feldery)) | |
{ | |
SetIsoInselHausStadtNr(aktinsel, akthaus, aktsave[i].ausricht, | |
aktsave[i].posx, aktsave[i].posy, aktsave[i].stadtnr); | |
KorrIsoHausProdTyp(aktinsel, akthaus, aktsave[i].stadtnr, | |
aktsave[i].ausricht, aktsave[i].posx, aktsave[i].posy, aktsave[i].randnr); | |
SetIsoInselHausAll(aktinsel, akthaus, aktsave[i].ausricht, | |
aktsave[i].posx, aktsave[i].posy, aktsave[i].animcnt); | |
if ((aktsave[i].stadtnr == NOSTADT)// Zur PROBE!! - Kann später | |
rauskommen !! | |
&& (akthaus->kind != HAUS_RUINE) | |
&& (akthaus->kind != HAUS_STRANDRUINE) | |
&& (!CheckIsoProdAllStatus(akthaus))) | |
{ | |
SetIsoInselHausOriginal(aktinsel, akthaus, aktsave[i].ausricht, | |
aktsave[i].posx, aktsave[i].posy, aktsave[i].animcnt); | |
} | |
} | |
} | |
} | |
} | |
} | |
else if (strcmp(name, "INSEL5") == 0) | |
{ | |
TINSELSAVE *inselsave = mem; | |
saveanz = lengh/sizeof(*inselsave); | |
for (i = 0; i < saveanz; i++) | |
{ | |
/*---Insel mit Grunddaten initialisieren---*/ | |
if (iso_load_insel != NULL) | |
{ | |
aktinsel = iso_load_insel; | |
if ((aktinsel->nativeflg)&&(inselsave[i].filenr!=NOFILE)) | |
inselsave[i].orginalflg = FALSE; | |
SetNewIsoInsel(aktinsel, aktinsel->posx, aktinsel->posy, | |
inselsave[i].felderx, inselsave[i].feldery); | |
} | |
else if (iso_noclear) | |
{ | |
aktinsel = iso_bau_insel; | |
SetNewIsoInsel(aktinsel, aktinsel->posx, aktinsel->posy, | |
aktinsel->felderx, aktinsel->feldery); | |
} | |
else | |
{ | |
aktinsel = &iso_insel[inselsave[i].inselnr]; | |
SetNewIsoInsel(aktinsel, inselsave[i].posx, inselsave[i].posy, | |
inselsave[i].felderx, inselsave[i].feldery); | |
} | |
/*---Stimmt Größe mit Sizenr überein---*/ | |
if (inselsave[i].felderx <= 32) inselsave[i].sizenr = 0; | |
else if (inselsave[i].felderx <= 42) inselsave[i].sizenr = 1; | |
else if (inselsave[i].felderx <= 55) inselsave[i].sizenr = 2; | |
else if (inselsave[i].felderx <= 75) inselsave[i].sizenr = 3; | |
else if (inselsave[i].felderx <= 110) inselsave[i].sizenr = 4; | |
/*---Filenummer und Größe der Insel herausfinden---*/ | |
sizenr = inselsave[i].sizenr; | |
filenr = inselsave[i].filenr; | |
klimanr = inselsave[i].klimanr; | |
/*---Orginal-Inseldaten einlesen---*/ | |
if ((filenr != NOFILE)&&(!inselsave[i].orginalflg)&&(ctrl_mode != | |
GADCTRL_SCAPE)) | |
{ | |
sprintf(inselname, "%s%s%s%02d.SCP", path_gam, | |
insel_klima_path[klimanr], insel_size_name[sizenr], filenr); | |
if ((fp = OpenFileR(inselname)) != NULL) | |
{ | |
if (iso_load_insel != NULL) | |
{ | |
ReadIsoGameData(fp, "INSELHAUS", FALSE); | |
} | |
else | |
{ | |
iso_load_insel = aktinsel; | |
ReadIsoGameData(fp, "INSELHAUS", FALSE); | |
iso_load_insel = NULL; | |
} | |
CloseFile(fp); | |
} | |
} | |
/*---Sonstige Inselvariablen setzen---*/ | |
aktinsel->filenr = filenr; | |
aktinsel->klimanr = klimanr; | |
aktinsel->sizenr = sizenr; | |
aktinsel->orginalflg = inselsave[i].orginalflg; | |
aktinsel->speedcnt = inselsave[i].speedcnt; | |
aktinsel->hirschreviercnt = inselsave[i].hirschreviercnt; | |
aktinsel->schatzflg = inselsave[i].schatzflg; | |
aktinsel->rohstanz = inselsave[i].rohstanz; | |
aktinsel->rohstflags = inselsave[i].rohstflags; | |
aktinsel->playerflags = inselsave[i].playerflags; | |
aktinsel->seeplayerflags = inselsave[i].seeplayerflags; | |
aktinsel->eisencnt = inselsave[i].eisencnt; | |
aktinsel->rotier = inselsave[i].rotier; | |
aktinsel->duerrproz = inselsave[i].duerrproz; | |
aktinsel->duerrcnt = inselsave[i].duerrcnt; | |
aktinsel->strtduerrflg = inselsave[i].strtduerrflg; | |
aktinsel->vulkanflg = inselsave[i].vulkanflg; | |
aktinsel->vulkancnt = inselsave[i].vulkancnt; | |
aktinsel->nofixflg = inselsave[i].nofixflg; | |
aktinsel->rohstflags|= ROHST_EVERMASK; | |
for (nr = inselsave[i].eisencnt-1; nr >= 0; nr--) | |
aktinsel->eisenberg[nr] = inselsave[i].eisenberg[nr]; | |
for (nr = inselsave[i].vulkancnt-1; nr >= 0; nr--) | |
aktinsel->vulkanberg[nr] = inselsave[i].vulkanberg[nr]; | |
} | |
/*========================================+ | |
I Insel-Daten abspeichern !! I | |
+=========================================*/ | |
void WriteIsoInsel(TISOINSEL *aktinsel, FILE *fpOut) | |
{ | |
int i, nr; | |
int x, y; | |
int feldoffs; | |
int upperx, uppery; | |
int addanz, feldanz; | |
UINT inselnr, stadtnr, playernr; | |
BOOL saveflg; | |
TISOFELD *aktfeld, *aktfeldo; | |
TISOSTADT *aktstadt; | |
TISOHAUS *akthaus; | |
THIRSCH *akthirsch; | |
#ifdef MAXFUN | |
TINSELSAVE_MAXFUN *inselsave; | |
#else | |
TINSELSAVE *inselsave; | |
#endif | |
THIRSCHSAVE *hirschsave; | |
TISOSAVE *aktsave, *worksave; | |
/*---Speicher besorgen---*/ | |
if ((inselsave = vallocRW(sizeof(*inselsave))) != NULL) | |
{ | |
/*---Welche Spieler müßten die Insel schon erkundet haben---*/ | |
BYTE playerflags = 0; | |
for (stadtnr = 0; stadtnr < MAXINSELSTADT; stadtnr++) | |
{ | |
if (((aktstadt = aktinsel->stadt[stadtnr]) != NULL) | |
&& (CheckPlayerFull(aktstadt->playernr))) | |
{ | |
playerflags|= (1<<aktstadt->playernr); | |
} | |
} | |
/*---Insel-Daten merken---*/ | |
inselnr = aktinsel->inselnr; | |
inselsave->inselnr = inselnr; | |
inselsave->posx = aktinsel->posx; | |
inselsave->posy = aktinsel->posy; | |
inselsave->felderx = aktinsel->felderx; | |
inselsave->feldery = aktinsel->feldery; | |
inselsave->speedcnt = aktinsel->speedcnt; | |
inselsave->hirschreviercnt = aktinsel->hirschreviercnt; | |
inselsave->schatzflg = aktinsel->schatzflg; | |
inselsave->orginalflg = aktinsel->orginalflg; | |
inselsave->nofixflg = aktinsel->nofixflg; | |
inselsave->rohstanz = aktinsel->rohstanz; | |
inselsave->rohstflags = aktinsel->rohstflags; | |
inselsave->filenr = aktinsel->filenr; | |
inselsave->klimanr = aktinsel->klimanr; | |
inselsave->sizenr = aktinsel->sizenr; | |
inselsave->seeplayerflags = aktinsel->seeplayerflags; | |
inselsave->eisencnt = aktinsel->eisencnt; | |
inselsave->duerrproz = aktinsel->duerrproz; | |
inselsave->duerrcnt = aktinsel->duerrcnt; | |
inselsave->strtduerrflg = aktinsel->strtduerrflg; | |
inselsave->vulkanflg = aktinsel->vulkanflg; | |
inselsave->vulkancnt = aktinsel->vulkancnt; | |
#ifdef MISSIONEDIT | |
inselsave->playerflags = playerflags; | |
#else | |
inselsave->playerflags = aktinsel->playerflags; | |
#endif | |
/*---Erzvorkommen abspeichern---*/ | |
for (nr = aktinsel->eisencnt-1; nr >= 0; nr--) | |
{ | |
inselsave->eisenberg[nr] = aktinsel->eisenberg[nr]; | |
#ifdef MISSIONEDIT | |
inselsave->eisenberg[nr].playerflags = playerflags; | |
#endif | |
} | |
/*---Vulkanvorkommen abspeichern---*/ | |
for (nr = aktinsel->vulkancnt-1; nr >= 0; nr--) | |
{ | |
inselsave->vulkanberg[nr] = aktinsel->vulkanberg[nr]; | |
} | |
/*---Welche Städtenummern sind belegt---*/ | |
for (stadtnr = 0; stadtnr < MAXINSELSTADT; stadtnr++) | |
{ | |
if ((aktstadt = aktinsel->stadt[stadtnr]) != NULL) | |
inselsave->stadtplayernr[stadtnr] = aktstadt->playernr; | |
else inselsave->stadtplayernr[stadtnr] = NOPLAYER; | |
} | |
/*---Daten abspeichern---*/ | |
#ifdef MAXFUN | |
WriteChunk("INSEL_MAXFUN", inselsave, sizeof(*inselsave), fpOut); | |
#else | |
WriteChunk("INSEL5", inselsave, sizeof(*inselsave), fpOut); | |
#endif | |
vfree(inselsave); | |
} | |
/*---Eigentliche Felddaten abspeichern---*/ | |
if ((aktsave = | |
vallocRW(aktinsel->felderx*aktinsel->feldery*sizeof(TISOSAVE))) != NULL) | |
{ | |
/*---Vordergrund == Hintergrunddaten---*/ | |
CopyIsoInselBackToFront(aktinsel); | |
inselnr = aktinsel->inselnr; | |
/*---Original Inseldaten sichern---*/ | |
// if ((aktinsel->orginalflg)||(aktinsel->filenr == NOFILE)) | |
{ | |
aktfeldo = aktinsel->feldo; | |
worksave = aktsave; | |
feldanz = 0; | |
for (y = 0; y < aktinsel->feldery; y++) | |
{ | |
for (x = 0; x < aktinsel->felderx; x++) | |
{ | |
feldoffs = y*aktinsel->felderx+x; | |
akthaus = GetIsoFeldHausCornerPos(&aktfeldo[feldoffs], x, y, | |
&upperx, &uppery); | |
if ((x == upperx)&&(y == uppery)) | |
{ | |
int animcnt; | |
if (akthaus->animanz != 0) | |
animcnt = aktfeldo[feldoffs].animcnt%akthaus->animanz; | |
else animcnt = 0; | |
addanz = SetIsoHausToSaveBuf(worksave, akthaus, | |
aktfeldo[feldoffs].ausricht, inselnr, NOSTADT, NOPLAYER, x, y, animcnt); | |
worksave+= addanz; | |
feldanz+= addanz; | |
} | |
} | |
} | |
WriteChunk("INSELHAUS", aktsave, feldanz*sizeof(TISOSAVE), fpOut); | |
} | |
/*---Vordergrund-Inseldaten sichern---*/ | |
aktfeldo = aktinsel->feldo; | |
aktfeld = aktinsel->feld; | |
worksave = aktsave; | |
feldanz = 0; | |
for (y = 0; y < aktinsel->feldery; y++) | |
{ | |
for (x = 0; x < aktinsel->felderx; x++) | |
{ | |
feldoffs = y*aktinsel->felderx+x; | |
akthaus = GetIsoFeldHausCornerPos(&aktfeld[feldoffs], x, y, &upperx, | |
&uppery); | |
saveflg = !CheckIsoFeldEqual(&aktfeld[feldoffs], | |
&aktfeldo[feldoffs]); | |
if ((x == upperx)&&(y == uppery)&&(saveflg)) | |
{ | |
int animcnt; | |
if (akthaus->animanz != 0) | |
animcnt = aktfeld[feldoffs].animcnt%akthaus->animanz; | |
else animcnt = 0; | |
if ((stadtnr = aktfeld[feldoffs].stadtnr) != NOSTADT) | |
playernr = aktinsel->stadt[stadtnr]->playernr; | |
else playernr = NOPLAYER; | |
addanz = SetIsoHausToSaveBuf(worksave, akthaus, | |
aktfeld[feldoffs].ausricht, inselnr, stadtnr, playernr, x, y, animcnt); | |
worksave+= addanz; | |
feldanz+= addanz; | |
} | |
} | |
} | |
WriteChunk("INSELHAUS", aktsave, feldanz*sizeof(TISOSAVE), fpOut); | |
/*---Buffer wieder freigeben---*/ | |
vfree(aktsave); | |
} | |
} | |
/*========================================+ | |
I Beschreibung zum Abspeichern eines I | |
I Hauses in der Landschaft !! I | |
+=========================================*/ | |
typedef struct { | |
UWORD id; | |
BYTE posx; | |
BYTE posy; | |
UINT ausricht:2; | |
UINT animcnt:4; | |
UINT inselnr:8; | |
UINT stadtnr:3; | |
UINT randnr:5; | |
UINT playernr:4; | |
} TISOSAVE; | |
/*========================================+ | |
I Structur SAVE-Landschaftsteil !! I | |
+=========================================*/ | |
typedef struct { | |
BYTE inselnr; | |
BYTE felderx; | |
BYTE feldery; | |
BYTE strtduerrflg:1; | |
BYTE nofixflg:1; | |
BYTE vulkanflg:1; | |
UWORD posx; | |
UWORD posy; | |
UWORD hirschreviercnt; | |
UWORD speedcnt; | |
BYTE stadtplayernr[11]; | |
BYTE vulkancnt; | |
BYTE schatzflg; | |
BYTE rohstanz; | |
BYTE eisencnt; | |
BYTE playerflags; | |
TERZBERG eisenberg[4]; | |
TERZBERG vulkanberg[4]; | |
UINT rohstflags; | |
UWORD filenr; | |
UWORD sizenr; | |
BYTE klimanr; | |
BYTE orginalflg; | |
BYTE duerrproz; | |
BYTE rotier; | |
UINT seeplayerflags; | |
UINT duerrcnt; | |
UINT leer3; | |
} TINSELSAVE; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment