Free Hero Mesh

Check-in [28294a20b2]
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:Fix connection moving so that HIT/HITBY during the second phase are sorted and that even if one fails, it will try all of them in order that shoving etc will be all or nothing.
Downloads: Tarball | ZIP archive | SQL archive
Timelines: family | ancestors | descendants | both | trunk
Files: files | file ages | folders
SHA1: 28294a20b27f226ce114a0683820c004741c4e45
User & Date: user on 2022-02-12 00:59:53
Other Links: manifest | tags
Context
2022-02-13
19:32
Implement XStep and YStep instructions. check-in: a6d1d398e5 user: user tags: trunk
2022-02-12
00:59
Fix connection moving so that HIT/HITBY during the second phase are sorted and that even if one fails, it will try all of them in order that shoving etc will be all or nothing. check-in: 28294a20b2 user: user tags: trunk
2022-02-11
22:34
When checking for CollisionLayers during connection movement, ignore objects that are also moving at the same time. check-in: d05fed08fd user: user tags: trunk
Changes

Modified exec.c from [6af053ca03] to [369c2612d9].

1148
1149
1150
1151
1152
1153
1154

1155
1156
1157
1158
1159
1160
1161
}

static int connected_move(Uint32 obj,Uint8 dir) {
  Object*o;
  Uint32 n;
  Sint32 inertia=objects[obj]->inertia;
  Sint32 weight=0;

  int first=nconn;
  int last;
  int i,j;
  if(nconn!=pconn) Throw("Improper nested connected move");
  // Find and add all connections
  add_connection(obj);
  for(i=first;i<nconn;i++) {







>







1148
1149
1150
1151
1152
1153
1154
1155
1156
1157
1158
1159
1160
1161
1162
}

static int connected_move(Uint32 obj,Uint8 dir) {
  Object*o;
  Uint32 n;
  Sint32 inertia=objects[obj]->inertia;
  Sint32 weight=0;
  char bad;
  int first=nconn;
  int last;
  int i,j;
  if(nconn!=pconn) Throw("Improper nested connected move");
  // Find and add all connections
  add_connection(obj);
  for(i=first;i<nconn;i++) {
1170
1171
1172
1173
1174
1175
1176

1177


1178
1179
1180
1181
1182
1183
1184
1185
1186
1187
1188
1189
1190
1191
1192
1193
1194
1195
1196
1197
1198
1199
1200
1201

1202
1203
1204
1205
1206
1207
1208
1209
1210
1211
1212
1213
1214
1215
1216
1217
1218
1219
1220
1221
1222
1223
1224
1225
1226
      if(o->inertia<weight) goto fail;
      inertia-=o->weight;
    }
  } else {
    weight=objects[conn[first].obj]->weight;
  }
  last=pconn=nconn;

  // Check HIT/HITBY; may shove other objects


  if(conn_option&0x02) {
    for(i=first;i<last;i++) {
      o=objects[n=conn[i].obj];
      j=fake_move_dir(n,o->dir=dir,1);
      if(!j) goto fail;
      if(j==2) {
        if(nconn==pconn) Throw("This object cannot be sticky");
        i=pconn;
        goto loop1;
      }
    }
  }
  for(i=first;i<last;i++) {
    o=objects[n=conn[i].obj];
    if(conn_option&0x01) o->inertia=inertia;
    j=fake_move_dir(n,o->dir=dir,0);
    if(!j) goto fail;
    if((conn_option&0x01) && !(o->oflags&OF_DESTROYED)) inertia=o->inertia;
    if(j==2) {
      if(nconn==pconn) Throw("This object cannot be sticky");
      i=pconn;
      goto loop1;
    }
  }

  // Check if each object in the group is movable
  for(i=first;i<last;i++) {
    o=objects[n=conn[i].obj];
    if(v_bool(send_message(VOIDLINK,n,MSG_MOVING,NVALUE(o->x+x_delta[dir]),NVALUE(o->y+y_delta[dir]),NVALUE(0)))) goto fail;
    if(classes[o->class]->cflags&CF_PLAYER) {
      n=lastobj;
      while(n!=VOIDLINK) {
        if(v_bool(send_message(conn[i].obj,n,MSG_PLAYERMOVING,NVALUE(o->x+x_delta[dir]),NVALUE(o->y+y_delta[dir]),NVALUE(0)))) goto fail;
        n=objects[n]->prev;
      }
    }
    if(j=classes[o->class]->collisionLayers) {
      if(connection_collision(j,o->x+x_delta[dir],o->y+y_delta[dir])) goto fail;
    }
  }
  // Move everything in the group
  conn_dir=dir;
  qsort(conn+first,last-first,sizeof(Connection),compare_connection);
  for(i=first;i<last;i++) {
    o=objects[n=conn[i].obj];
    if(!conn[i].visual) o->oflags&=~OF_VISUALONLY;
    if(move_to(obj,n,o->x+x_delta[dir],o->y+y_delta[dir])) o->oflags|=OF_MOVED;
  }
  // Done
  j=1; goto done;







>

>
>
















|







>
















<
<







1171
1172
1173
1174
1175
1176
1177
1178
1179
1180
1181
1182
1183
1184
1185
1186
1187
1188
1189
1190
1191
1192
1193
1194
1195
1196
1197
1198
1199
1200
1201
1202
1203
1204
1205
1206
1207
1208
1209
1210
1211
1212
1213
1214
1215
1216
1217
1218
1219
1220
1221
1222


1223
1224
1225
1226
1227
1228
1229
      if(o->inertia<weight) goto fail;
      inertia-=o->weight;
    }
  } else {
    weight=objects[conn[first].obj]->weight;
  }
  last=pconn=nconn;
  bad=0;
  // Check HIT/HITBY; may shove other objects
  conn_dir=dir;
  qsort(conn+first,last-first,sizeof(Connection),compare_connection);
  if(conn_option&0x02) {
    for(i=first;i<last;i++) {
      o=objects[n=conn[i].obj];
      j=fake_move_dir(n,o->dir=dir,1);
      if(!j) goto fail;
      if(j==2) {
        if(nconn==pconn) Throw("This object cannot be sticky");
        i=pconn;
        goto loop1;
      }
    }
  }
  for(i=first;i<last;i++) {
    o=objects[n=conn[i].obj];
    if(conn_option&0x01) o->inertia=inertia;
    j=fake_move_dir(n,o->dir=dir,0);
    if(!j) bad=1;
    if((conn_option&0x01) && !(o->oflags&OF_DESTROYED)) inertia=o->inertia;
    if(j==2) {
      if(nconn==pconn) Throw("This object cannot be sticky");
      i=pconn;
      goto loop1;
    }
  }
  if(bad) goto fail;
  // Check if each object in the group is movable
  for(i=first;i<last;i++) {
    o=objects[n=conn[i].obj];
    if(v_bool(send_message(VOIDLINK,n,MSG_MOVING,NVALUE(o->x+x_delta[dir]),NVALUE(o->y+y_delta[dir]),NVALUE(0)))) goto fail;
    if(classes[o->class]->cflags&CF_PLAYER) {
      n=lastobj;
      while(n!=VOIDLINK) {
        if(v_bool(send_message(conn[i].obj,n,MSG_PLAYERMOVING,NVALUE(o->x+x_delta[dir]),NVALUE(o->y+y_delta[dir]),NVALUE(0)))) goto fail;
        n=objects[n]->prev;
      }
    }
    if(j=classes[o->class]->collisionLayers) {
      if(connection_collision(j,o->x+x_delta[dir],o->y+y_delta[dir])) goto fail;
    }
  }
  // Move everything in the group


  for(i=first;i<last;i++) {
    o=objects[n=conn[i].obj];
    if(!conn[i].visual) o->oflags&=~OF_VISUALONLY;
    if(move_to(obj,n,o->x+x_delta[dir],o->y+y_delta[dir])) o->oflags|=OF_MOVED;
  }
  // Done
  j=1; goto done;