Overview
Comment: | Implement objtrash() and generation number increasing; move initialization to a separate subroutine |
---|---|
Downloads: | Tarball | ZIP archive | SQL archive |
Timelines: | family | ancestors | descendants | both | trunk |
Files: | files | file ages | folders |
SHA1: |
daf44d7fbb9cfcf418b4a477403c9ba6 |
User & Date: | user on 2020-11-26 01:41:03 |
Other Links: | manifest | tags |
Context
2020-11-26
| ||
01:53 | Fix implementation of some opcodes. check-in: 5aa3128a59 user: user tags: trunk | |
01:41 | Implement objtrash() and generation number increasing; move initialization to a separate subroutine check-in: daf44d7fbb user: user tags: trunk | |
2020-11-24
| ||
00:45 | Add a file for copying sounds from HEROFALL.EXE check-in: 043f25eb8d user: user tags: trunk | |
Changes
Modified exec.c from [ca6634bfb7] to [6040730ffa].
︙ | |||
23 24 25 26 27 28 29 30 31 32 33 34 35 36 | 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 | + | Uint32 nobjects; Value globals[0x800]; Uint32 firstobj=VOIDLINK; Uint32 lastobj=VOIDLINK; Uint32 playfield[64*64]; Uint8 pfwidth,pfheight; Sint8 gameover,key_ignored; Uint8 generation_number_inc; typedef struct { Uint16 msg; Uint32 from; Value arg1,arg2,arg3; } MessageVars; |
︙ | |||
81 82 83 84 85 86 87 88 89 90 91 92 93 94 | 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 | + + + + + | Uint32 n; Class*cl=classes[c]; Object*o=0; if(!c || !cl || cl->cflags&(CF_GROUP|CF_NOCLASS2)) goto bad; o=calloc(1,sizeof(Object)+cl->uservars*sizeof(Value)); if(!o) fatal("Allocation failed\n"); o->class=c; if(generation_number_inc) { generation_number_inc=0; ++generation_number; if(generation_number<=TY_MAXTYPE) goto bad; } o->generation=generation_number; #define C(x) o->x=cl->x; C(height) C(weight) C(climb) C(density) C(volume) C(strength) C(arrivals) C(departures) C(temperature) C(shape) C(shovable) C(oflags) C(sharp[0]) C(sharp[1]) C(sharp[2]) C(sharp[3]) C(hard[0]) C(hard[1]) C(hard[2]) C(hard[3]) #undef C |
︙ | |||
116 117 118 119 120 121 122 123 124 125 126 127 128 129 | 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 | + + + + + + + + + + + + + + + + | } objects[n]=o; return n; bad: free(o); return VOIDLINK; } void objtrash(Uint32 n) { Object*o=objects[n]; if(!o) return; if(o->down==VOIDLINK) playfield[o->x+o->y*64-65]=o->up; else objects[o->down]->up=o->up; if(o->up!=VOIDLINK) objects[o->up]->down=o->down; o->down=o->up=VOIDLINK; if(firstobj==n) firstobj=o->next; if(lastobj==n) lastobj=o->prev; if(o->prev) objects[o->prev]->next=o->next; if(o->next) objects[o->next]->prev=o->prev; free(o); objects[n]=0; generation_number_inc=1; } static inline int v_bool(Value v) { switch(v.t) { case TY_NUMBER: return v.u!=0; case TY_SOUND: case TY_USOUND: Throw("Cannot convert sound to boolean"); default: return 1; } |
︙ | |||
217 218 219 220 221 222 223 | 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 | - + + + + + + + + + + + + + | nobjects=0; free(objects); objects=0; gameover=0; } const char*execute_turn(int key) { |
Modified heromesh.h from [7f03c73a50] to [febc731348].
︙ | |||
189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 | 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 | + + + | extern Object**objects; extern Uint32 nobjects; extern Value globals[0x800]; extern Uint32 firstobj,lastobj; extern Uint32 playfield[64*64]; extern Uint8 pfwidth,pfheight; extern Sint8 gameover,key_ignored; extern Uint8 generation_number_inc; void pfunlink(Uint32 n); void pflink(Uint32 n); Uint32 objalloc(Uint16 c); void objtrash(Uint32 n); void annihilate(void); const char*execute_turn(int key); const char*init_level(void); // == game == void run_game(void); // == edit == |
︙ |
Modified main.c from [fec4beb6eb] to [64955f8adb].
︙ | |||
212 213 214 215 216 217 218 219 220 221 222 223 224 225 | 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 | + | } if(lvl<0) return "Invalid level ID"; if(!buf) return "Cannot find level"; free(level_title); level_title=0; annihilate(); generation_number=TY_MAXTYPE+1; generation_number_inc=0; level_version=p[0]|(p[1]<<8); level_code=p[2]|(p[3]<<8); p+=4; pfwidth=(*p++&63)+1; pfheight=(*p++&63)+1; while(*p && p<end) p++; // skip text for now p++; // skip null terminator |
︙ |