Free Hero Mesh

Check-in [cb5540680c]
Login
This is a mirror of the main repository for Free Hero Mesh. New tickets and changes will not be accepted at this mirror.
Overview
Comment:Implement "traceObject" resource to halt when a specific object is destroyed
Downloads: Tarball | ZIP archive | SQL archive
Timelines: family | ancestors | descendants | both | trunk
Files: files | file ages | folders
SHA1: cb5540680ca02638780698616c9744a519929fc3
User & Date: user on 2020-12-18 20:46:15
Other Links: manifest | tags
Context
2020-12-19
05:47
Add documentation about command-line arguments check-in: cb27aaf96b user: user tags: trunk
2020-12-18
20:46
Implement "traceObject" resource to halt when a specific object is destroyed check-in: cb5540680c user: user tags: trunk
19:36
Improve the error message for "Attempt to use a nonexistent object"; shortcut checking if oF is VOIDLINK in move_dir check-in: 48e77da6af user: user tags: trunk
Changes

Modified exec.c from [5bd169313d] to [170a3bb7c5].

44
45
46
47
48
49
50

51
52
53
54
55
56
57
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58







+







static MessageVars msgvars;
static char lastimage_processing,changed,all_flushed;
static Value vstack[VSTACKSIZE];
static int vstackptr;
static const char*traceprefix;
static Uint8 current_key;
static Value quiz_obj;
static Value traced_obj;

#define Throw(x) (my_error=(x),longjmp(my_env,1))
#define StackReq(x,y) do{ if(vstackptr<(x)) Throw("Stack underflow"); if(vstackptr-(x)+(y)>=VSTACKSIZE) Throw("Stack overflow"); }while(0)
#define Push(x) (vstack[vstackptr++]=(x))
#define Pop() (vstack[--vstackptr])

// For arrival/departure masks
154
155
156
157
158
159
160




161
162
163
164
165
166
167
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172







+
+
+
+







}

#define animfree free

void objtrash(Uint32 n) {
  Object*o=objects[n];
  if(!o) return;
  if(n==traced_obj.u && o->generation==traced_obj.t && main_options['t'] && !main_options['e']) {
    printf("# Object traced at (%d,%d)\n",o->x,o->y);
    Throw("Object traced");
  }
  animfree(o->anim);
  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;
  if(!(o->oflags&OF_DESTROYED)) {
    if(firstobj==n) firstobj=o->next;
    if(lastobj==n) lastobj=o->prev;
446
447
448
449
450
451
452
453

454
455
456
457
458
459
460
451
452
453
454
455
456
457

458
459
460
461
462
463
464
465







-
+








static Uint32 v_object(Value v) {
  if(v.t==TY_NUMBER) {
    if(v.u) Throw("Cannot convert non-zero number to object");
    return VOIDLINK;
  } else if(v.t>TY_MAXTYPE) {
    if(v.u>=nobjects || !objects[v.u] || objects[v.u]->generation!=v.t) {
      if(main_options['t']) printf("Object %lu in generation %lu does not exist\n",(long)v.u,(long)v.t);
      if(main_options['t']) printf("[Object %lu in generation %lu does not exist]\n",(long)v.u,(long)v.t);
      Throw("Attempt to use a nonexistent object");
    }
    return v.u;
  } else {
    Throw("Cannot convert non-object to object");
  }
}
1671
1672
1673
1674
1675
1676
1677

1678













1679
1680
1681
1682
1683
1684
1685
1676
1677
1678
1679
1680
1681
1682
1683

1684
1685
1686
1687
1688
1689
1690
1691
1692
1693
1694
1695
1696
1697
1698
1699
1700
1701
1702
1703







+
-
+
+
+
+
+
+
+
+
+
+
+
+
+







  if(generation_number<=TY_MAXTYPE) return "Too many generations of objects";
  // Finished
  return 0;
}

const char*init_level(void) {
  if(setjmp(my_env)) return my_error;
  if(main_options['t']) {
  if(main_options['t']) printf("[Level %d restarted]\n",level_id);
    printf("[Level %d restarted]\n",level_id);
    if(!traced_obj.t) {
      const char*s;
      optionquery[1]=Q_traceObject;
      if(s=xrm_get_resource(resourcedb,optionquery,optionquery,2)) {
        traced_obj.u=strtol(s,(char**)&s,10);
        if(*s==':') traced_obj.t=strtol(s+1,0,10);
        printf("Tracing object <%ld:%ld>\n",(long)traced_obj.u,(long)traced_obj.t);
      } else {
        traced_obj.t=TY_FOR;
      }
    }
  }
  memcpy(globals,initglobals,sizeof(globals));
  quiz_obj=NVALUE(0);
  gameover=0;
  changed=0;
  key_ignored=0;
  all_flushed=0;
  lastimage_processing=0;

Modified quarks from [517c4fed48] to [3b8f040017].

210
211
212
213
214
215
216

217
210
211
212
213
214
215
216
217
218







+


! Miscellaneous
level
tracePrefix
stackProtection
maxObjects
traceAll
traceObject

Modified quarks.h from [10675a056f] to [1834c51d24].

175
176
177
178
179
180
181

182
183
184
185
186
187
188
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189







+







#define Q_sqlCoveringIndexScan 176
#define Q_sqlPowerSafe 177
#define Q_level 178
#define Q_tracePrefix 179
#define Q_stackProtection 180
#define Q_maxObjects 181
#define Q_traceAll 182
#define Q_traceObject 183
static const char*const global_quarks[]={
  "screenWidth",
  "screenHeight",
  "margin",
  "palette",
  "popupColors",
  "imageSize",
357
358
359
360
361
362
363

364
365
366
367
368
369
370
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372







+







  "sqlCoveringIndexScan",
  "sqlPowerSafe",
  "level",
  "tracePrefix",
  "stackProtection",
  "maxObjects",
  "traceAll",
  "traceObject",
0};
#ifdef HEROMESH_BINDINGS
static const SDLKey quark_to_key[Q_undo+1-Q_backspace]={
SDLK_BACKSPACE,
SDLK_TAB,
SDLK_CLEAR,
SDLK_RETURN,