author | ecalot
<ecalot> 2004-08-25 01:08:35 UTC |
committer | ecalot
<ecalot> 2004-08-25 01:08:35 UTC |
parent | 3421dbba085cb6f7de89a17f581d6f995c6d85db |
FP/src/include/types.h | +1 | -3 |
FP/src/res/maps.c | +15 | -2 |
diff --git a/FP/src/include/types.h b/FP/src/include/types.h index 00b877e..3e37ff3 100644 --- a/FP/src/include/types.h +++ b/FP/src/include/types.h @@ -55,9 +55,7 @@ typedef struct { unsigned char back [24*30]; tGate** screenGates[24]; tGate* gates; - /* - * Active door handling here - * */ + tEvent events[256]; int time; unsigned char start[3]; } tMap; diff --git a/FP/src/res/maps.c b/FP/src/res/maps.c index 8548247..98d63fe 100644 --- a/FP/src/res/maps.c +++ b/FP/src/res/maps.c @@ -73,6 +73,8 @@ void* mapLoadLevel(tMemory level) { int gates=0; int gateInRoom=0; int change=-1; + tGate** auxGates=malloc(sizeof(tGate*)*24*30); + /* copy maps, links and start position */ memcpy(map->fore,level.array+MAPS_BLOCK_OFFSET_WALL,30*24); memcpy(map->back,level.array+MAPS_BLOCK_OFFSET_BACK,30*24); @@ -81,6 +83,7 @@ void* mapLoadLevel(tMemory level) { /* generate and load gate structures */ for (i=0;i<30*24;i++) { /* count gates and create gate tree middle nodes */ + auxGates[i]=NULL; /* clear array */ if ((map->fore[i]==T_GATE)||(map->fore[i]==T_EXIT_LEFT)) { if (i/30!=change) { printf("Screen %d has %d gates.",change,gateInRoom); @@ -113,11 +116,21 @@ void* mapLoadLevel(tMemory level) { newGate.action=map->back[i]; map->back[i]=gateInRoom; map->screenGates[i/30][gateInRoom]=map->gates+gates; + auxGates[i]=map->gates+gates; map->gates[gates++]=newGate; } } - - + for (i=0;i<256;i++) { + unsigned char byte1=level.array[MAPS_BLOCK_OFFSET_GATE_1+i]; + unsigned char byte2=level.array[MAPS_BLOCK_OFFSET_GATE_2+i]; + int S,L,T; + S=((byte1>>5)&3)|((byte2>>3)&7); + L=byte1&31; + T=(byte1>>7)&1; + map->events[i].triggerNext=T; + map->events[i].gate=auxGates[(S-1)*30+L]; /* in case of error null is assigned */ + } + free(auxGates); return (void*)map; }