Overview
| Comment: | Add a "maxObjects" resource. Also add some missing "extern" from declarations in heromesh.h and add a hidden "heap test" option |
|---|---|
| Downloads: | Tarball | ZIP archive |
| Timelines: | family | ancestors | descendants | both | trunk |
| Files: | files | file ages | folders |
| SHA1: |
402432f1b2ea0aae65f9d30791623497 |
| User & Date: | user on 2018-07-10 05:56:03.404 |
| Other Links: | manifest | tags |
Context
|
2018-07-14
| ||
| 00:19 | Implement the "CLASSES" virtual table and the "CLASS_DATA" SQL function. check-in: 829b9ff683 user: user tags: trunk | |
|
2018-07-10
| ||
| 05:56 | Add a "maxObjects" resource. Also add some missing "extern" from declarations in heromesh.h and add a hidden "heap test" option check-in: 402432f1b2 user: user tags: trunk | |
|
2018-07-08
| ||
| 00:13 | Add some more stuff with graphics and some other stuff that was previously forgotten check-in: c5926b50b9 user: user tags: trunk | |
Changes
Modified exec.c
from [355c5a5b56]
to [89cee0572f].
| ︙ | ︙ | |||
9 10 11 12 13 14 15 16 17 18 19 20 21 22 | #include <stdlib.h> #include <string.h> #include "sqlite3.h" #include "smallxrm.h" #include "heromesh.h" #include "instruc.h" Uint32 generation_number; Object**objects; Uint32 nobjects; Value globals[0x800]; Uint32 firstobj=VOIDLINK; Uint32 lastobj=VOIDLINK; Uint32 playfield[64*64]; | > | 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 | #include <stdlib.h> #include <string.h> #include "sqlite3.h" #include "smallxrm.h" #include "heromesh.h" #include "instruc.h" Uint32 max_objects; Uint32 generation_number; Object**objects; Uint32 nobjects; Value globals[0x800]; Uint32 firstobj=VOIDLINK; Uint32 lastobj=VOIDLINK; Uint32 playfield[64*64]; |
| ︙ | ︙ | |||
60 61 62 63 64 65 66 |
if(t!=VOIDLINK) objects[t]->up=n; else playfield[p]=n;
if(m!=VOIDLINK) objects[m]->down=n;
}
}
#define OBJECT_ARRAY_BLOCK 256
Uint32 objalloc(Uint16 c) {
| | > > > | > > > | 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 |
if(t!=VOIDLINK) objects[t]->up=n; else playfield[p]=n;
if(m!=VOIDLINK) objects[m]->down=n;
}
}
#define OBJECT_ARRAY_BLOCK 256
Uint32 objalloc(Uint16 c) {
// Allocates a new object of the given class; links into the event list but not into the playfield.
// Does not send any messages or otherwise notify anyone that it has been created.
// Returns VOIDLINK if object cannot be created.
Uint32 n;
Class*cl=classes[c];
Object*o=calloc(1,sizeof(Object)+cl->uservars*sizeof(Value));
if(!c || !cl || cl->cflags&(CF_GROUP|CF_NOCLASS1|CF_NOCLASS2)) goto bad;
if(!o) fatal("Allocation failed\n");
o->class=c;
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
o->misc4=NVALUE(cl->misc4);
o->misc5=NVALUE(cl->misc5);
o->misc6=NVALUE(cl->misc6);
o->misc7=NVALUE(cl->misc7);
if(nobjects) for(n=nobjects-1;;n--) {
if(!objects[n]) goto found;
if(!n) break;
}
if(nobjects>=max_objects) goto bad;
objects=realloc(objects,(nobjects+OBJECT_ARRAY_BLOCK)*sizeof(Object*));
if(!objects) fatal("Allocation failed\n");
for(n=nobjects;n<nobjects+OBJECT_ARRAY_BLOCK;n++) objects[n]=0;
n=nobjects;
nobjects+=OBJECT_ARRAY_BLOCK;
found:
o->up=o->down=o->prev=o->next=VOIDLINK;
if(cl->nmsg || classes[0]->nmsg) {
o->prev=lastobj;
if(lastobj!=VOIDLINK) objects[lastobj]->next=n;
lastobj=n;
if(firstobj==VOIDLINK) firstobj=n;
}
objects[n]=o;
return n;
bad:
free(o);
return VOIDLINK;
}
static void execute_program(Uint16*code,int ptr,Uint32 obj) {
Object*o=objects[obj];
if(StackProtection()) Throw("Call stack overflow");
for(;;) switch(code[ptr++]) {
case OP_GOTO: ptr=code[ptr]; break;
|
| ︙ | ︙ |
Modified heromesh.h
from [d034a0352f]
to [2b83b24f84].
| ︙ | ︙ | |||
164 165 166 167 168 169 170 171 172 173 174 175 176 | Uint16 sharp[4]; Uint16 hard[4]; Uint8 x,y,shape,shovable,image,dir; Value misc1,misc2,misc3,misc4,misc5,misc6,misc7; Value uservars[0]; } Object; extern Uint32 generation_number; extern Object**objects; extern Uint32 nobjects; extern Value globals[0x800]; extern Uint32 firstobj,lastobj; extern Uint32 playfield[64*64]; | > | | 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 | Uint16 sharp[4]; Uint16 hard[4]; Uint8 x,y,shape,shovable,image,dir; Value misc1,misc2,misc3,misc4,misc5,misc6,misc7; Value uservars[0]; } Object; extern Uint32 max_objects; extern Uint32 generation_number; extern Object**objects; extern Uint32 nobjects; extern Value globals[0x800]; extern Uint32 firstobj,lastobj; extern Uint32 playfield[64*64]; extern Uint8 pfwidth,pfheight; void pfunlink(Uint32 n); void pflink(Uint32 n); Uint32 objalloc(Uint16 c); void annihilate(void); const char*execute_turn(int key); |
Modified main.c
from [2de729fbaa]
to [c418f63360].
| ︙ | ︙ | |||
582 583 584 585 586 587 588 589 590 591 592 593 594 595 |
v=xrm_get_resource(resourcedb,optionquery,optionquery,2);
if(!v || !*v) return;
stack_protect_mode=*v;
if(*v=='?') {
fprintf(stderr,"Stack protection test mode: %p\n",stack_protect_mark);
stack_protect_low=stack_protect_high=stack_protect_mark;
atexit(test_stack_protection);
}
if(v[1]) stack_protect_mark=((char*)stack_protect_mark)+strtoll(v+1,0,0);
}
#endif
int main(int argc,char**argv) {
int optind=1;
| > > > | 582 583 584 585 586 587 588 589 590 591 592 593 594 595 596 597 598 |
v=xrm_get_resource(resourcedb,optionquery,optionquery,2);
if(!v || !*v) return;
stack_protect_mode=*v;
if(*v=='?') {
fprintf(stderr,"Stack protection test mode: %p\n",stack_protect_mark);
stack_protect_low=stack_protect_high=stack_protect_mark;
atexit(test_stack_protection);
} else if(*v=='H') {
v=malloc(strtoll(v+1,0,0));
fatal("%p %p :: %lld\n",v,stack_protect_mark,(long long)(((char*)stack_protect_mark)-v));
}
if(v[1]) stack_protect_mark=((char*)stack_protect_mark)+strtoll(v+1,0,0);
}
#endif
int main(int argc,char**argv) {
int optind=1;
|
| ︙ | ︙ | |||
634 635 636 637 638 639 640 |
init_usercache();
load_classes();
if(main_options['x']) {
fprintf(stderr,"Ready for executing SQL statements.\n");
do_sql_mode();
return 0;
}
| | > | | 637 638 639 640 641 642 643 644 645 646 647 |
init_usercache();
load_classes();
if(main_options['x']) {
fprintf(stderr,"Ready for executing SQL statements.\n");
do_sql_mode();
return 0;
}
optionquery[1]=Q_maxObjects;
max_objects=strtoll(xrm_get_resource(resourcedb,optionquery,optionquery,2)?:"",0,0)?:0xFFFF0000L;
return 0; // for(;;) { if(main_options['e']) run_editor(); else run_game(); }
}
|
Modified quarks
from [4fe1d966b3]
to [a113357ac4].
| ︙ | ︙ | |||
207 208 209 210 211 212 213 214 | sqlCoveringIndexScan sqlPowerSafe ! Miscellaneous level tracePrefix stackProtection | > | 207 208 209 210 211 212 213 214 215 | sqlCoveringIndexScan sqlPowerSafe ! Miscellaneous level tracePrefix stackProtection maxObjects |
Modified quarks.h
from [2ba01dbe27]
to [6b9c60aaee].
| ︙ | ︙ | |||
172 173 174 175 176 177 178 179 180 181 182 183 184 185 |
#define Q_sqlMemStatus 173
#define Q_sqlSmallAllocations 174
#define Q_sqlCoveringIndexScan 175
#define Q_sqlPowerSafe 176
#define Q_level 177
#define Q_tracePrefix 178
#define Q_stackProtection 179
static const char*const global_quarks[]={
"screenWidth",
"screenHeight",
"margin",
"palette",
"popupColors",
"imageSize",
| > | 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 |
#define Q_sqlMemStatus 173
#define Q_sqlSmallAllocations 174
#define Q_sqlCoveringIndexScan 175
#define Q_sqlPowerSafe 176
#define Q_level 177
#define Q_tracePrefix 178
#define Q_stackProtection 179
#define Q_maxObjects 180
static const char*const global_quarks[]={
"screenWidth",
"screenHeight",
"margin",
"palette",
"popupColors",
"imageSize",
|
| ︙ | ︙ | |||
351 352 353 354 355 356 357 358 359 360 361 362 363 364 |
"sqlMemStatus",
"sqlSmallAllocations",
"sqlCoveringIndexScan",
"sqlPowerSafe",
"level",
"tracePrefix",
"stackProtection",
0};
#ifdef HEROMESH_BINDINGS
static const SDLKey quark_to_key[Q_undo+1-Q_backspace]={
SDLK_BACKSPACE,
SDLK_TAB,
SDLK_CLEAR,
SDLK_RETURN,
| > | 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 |
"sqlMemStatus",
"sqlSmallAllocations",
"sqlCoveringIndexScan",
"sqlPowerSafe",
"level",
"tracePrefix",
"stackProtection",
"maxObjects",
0};
#ifdef HEROMESH_BINDINGS
static const SDLKey quark_to_key[Q_undo+1-Q_backspace]={
SDLK_BACKSPACE,
SDLK_TAB,
SDLK_CLEAR,
SDLK_RETURN,
|
| ︙ | ︙ |