Overview
Comment: | Start to implement deferred movement (incomplete and untested so far). |
---|---|
Downloads: | Tarball | ZIP archive | SQL archive |
Timelines: | family | ancestors | descendants | both | trunk |
Files: | files | file ages | folders |
SHA1: |
13bc344828e21cf3d6141ceee014dbeb |
User & Date: | user on 2021-04-05 05:50:10 |
Other Links: | manifest | tags |
Context
2021-04-06
| ||
21:21 | Implement more of the deferred movement (untested so far, although it does compile). check-in: 6bc4ddf9d6 user: user tags: trunk | |
2021-04-05
| ||
05:50 | Start to implement deferred movement (incomplete and untested so far). check-in: 13bc344828 user: user tags: trunk | |
2021-04-03
| ||
00:30 | Fix the =Done instruction so that it clears the OF_DONE flag instead of the OF_BUSY flag. check-in: 72fc19f911 user: user tags: trunk | |
Changes
Modified class.doc from [13fb9f1df8] to [7f2eb9e655].
︙ | |||
878 879 880 881 882 883 884 885 886 887 888 889 890 891 | 878 879 880 881 882 883 884 885 886 887 888 889 890 891 892 893 894 895 | + + + + | Moved : bool After a Move instruction successfully moves this object, it will set this flag. During the trigger phase, it will send the MOVED message to all objects which have moved; you can set or clear this flag by yourself if you want to cause it to trigger even though it didn't move or to not trigger even though it did move. Moving : bool This flag indicates that a deferred movement is scheduled for this object. The direction of movement is specified by the Dir variable. Player : bool [c] [ro] If this object is the player. This is used implicitly as the From of some messages sent by the game engine, and has a few other purposes. (Normally, a level should have exactly one object of such a class, although this is not mandatory; any number (including zero) is allowed.) Shape : int16 [c] |
︙ | |||
905 906 907 908 909 910 911 | 909 910 911 912 913 914 915 916 917 918 919 920 921 922 923 924 | - - + + | values for the sides that are touching will be compared. If the Sharp value for one is greater than the Hard of the other, then the object with insufficient Hardness is destroyed. Shovable : int16 [c] Defines what directions the object may be shoved, where bit0 means east, bit2 means north, bit4 means west, and bit6 means south. Bit1, bit3, |
︙ | |||
1350 1351 1352 1353 1354 1355 1356 1357 1358 1359 1360 1361 1362 1363 | 1354 1355 1356 1357 1358 1359 1360 1361 1362 1363 1364 1365 1366 1367 1368 1369 1370 1371 1372 1373 1374 1375 1376 1377 1378 1379 1380 1381 1382 1383 1384 1385 1386 | + + + + + + + + + + + + + + + + + + + | Similar to Move but adds Strength to Inertia without resetting Inertia. (The reason this exists is for compatibility with a bug in EKS Hero Mesh; you probably do not need to use this yourself.) ,Move+ ( obj dir -- bool ) ** As Move+ but for a specified object. +Move ( dir -- bool ) ** Schedules a deferred move for this object in the specified direction (which may be absolute or relative). Some things are checked at this time, while other things are checked at the time that the movement will be made; its working is different from non-deferred movements. The result is true if the move was scheduled or false if it isn't. (Note: Do not confuse +Move with Move+; they are unrelated.) ,+Move ( obj dir -- bool ) ** As +Move but for a specified object rather than necessarily this one. -Move ( dir -- bool ) ** Cancel a deferred move in the specified direction, and possibly also other things that are shoved by it. The result will be true if it was scheduled and successfully removed, or false otherwise. ,-Move ( obj dir -- bool ) ** As -Move but for a specified object rather than necessarily this one. MoveNumber ( -- number ) The current move number. This is initially zero, and is advanced after each input phase (before the beginning phase). MoveTo ( x y -- bool ) ** Teleports this object to the specified coordinates; the MOVING message (and PLAYERMOVING if applicable) are sent to check if it is allowed. |
︙ | |||
1436 1437 1438 1439 1440 1441 1442 1443 1444 1445 1446 1447 1448 1449 | 1459 1460 1461 1462 1463 1464 1465 1466 1467 1468 1469 1470 1471 1472 1473 1474 1475 1476 1477 1478 | + + + + + + | from the specified object. ObjLayerAt ( layers x y -- obj ) Find an object with the given CollisionLayers bits set at that location. If you specify multiple bits, it finds one with any of those bits. (It is not possible for there to be more than one such object.) ObjMovingTo ( x y -- ... ) Push on the stack all objects scheduled to move to the specified X and Y coordinates. There may be zero or more such objects; you can add a mark to the stack in order to delimit this list (it won't do so automatically, since you may be putting multiple lists together). ObjTopAt ( x y -- obj ) Find the object on the top at the specified location. The result will be zero if that location is vacant or out of range. over ( x y -- x y x ) oz? ( any -- bool ) |
︙ | |||
1664 1665 1666 1667 1668 1669 1670 | 1693 1694 1695 1696 1697 1698 1699 1700 1701 1702 1703 1704 1705 1706 1707 1708 1709 1710 1711 1712 1713 1714 1715 1716 1717 1718 1719 1720 1721 1722 1723 1724 1725 1726 1727 1728 1729 1730 1731 1732 1733 1734 | + - + + + + + + + + + | Display a percentage sign; does not consume an argument. === Messages === This section describes when the various standard messages are sent to objects, and what return values are expected. (Do not confuse CREATE with CREATED, or DESTROY with DESTROYED, or COLLIDE with COLLIDING; they have |
︙ | |||
1707 1708 1709 1710 1711 1712 1713 1714 1715 1716 1717 1718 1719 1720 | 1745 1746 1747 1748 1749 1750 1751 1752 1753 1754 1755 1756 1757 1758 1759 1760 1761 1762 1763 1764 1765 1766 1767 1768 1769 1770 1771 1772 1773 1774 1775 1776 | + + + + + + + + + + + + + + + + + + | attempt is successful even if it isn't (there is no effect for creating objects; this bit is meaningful only for moves), and bit4 means that if necessary, it will try to destroy this object to make room. From is the object attempting to move here, and Arg1 and Arg2 are its location (if attempting to create an object, then From, Arg1, and Arg2 are all zero). Arg3 is the class of the object being moved or created. COLLIDING Called when deferred movement is being performed if the move cannot occur due to a collision with some other object. From is the object that it is colliding with, Arg1 and Arg2 are its location, and Arg3 is the type of collision (0 if this object is trying to move into a stationary object, 1 if another object is trying to move into this stationary object, 2 if two objects are trying to move into the same space, or 3 if two or more objects forming a loop are trying to move into each other). There is no guarantee that this will only be called once; sometimes it will be called multiple times for a single collision or for multiple collisions with the same objects. (TODO) CONFLICT Called during scheduling of a deferred move if it is already currently scheduled to move but in a different direction. Arg1 is the direction that it is trying to schedule the move in. If the return value is false then the schedule fails; if true, then it succeeds. CREATE Sent when the object is created by the Create instruction. This is done after the object is created, but before sending any other messages. The From is the object that created it. The return value will be used as the Arg3 of the SUNK and CREATED messages it might send if appropriate. From is the object which executed the Create instruction to create it. |
︙ |
Modified exec.c from [3dfcfca3a4] to [bffe9b84f5].
︙ | |||
1041 1042 1043 1044 1045 1046 1047 1048 1049 1050 1051 1052 1053 1054 | 1041 1042 1043 1044 1045 1046 1047 1048 1049 1050 1051 1052 1053 1054 1055 1056 1057 1058 1059 1060 1061 1062 1063 1064 1065 1066 1067 1068 1069 1070 1071 1072 1073 1074 1075 1076 1077 1078 1079 1080 1081 1082 1083 1084 1085 1086 1087 1088 1089 1090 1091 | + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + | if(n==VOIDLINK) return 0; xx=objects[n]->x; yy=objects[n]->y; if(!move_to(from,n,x,y)) return 0; send_message(VOIDLINK,n,MSG_JUMPED,NVALUE(xx),NVALUE(yy),OVALUE(from)); return 1; } static int defer_move(Uint32 obj,Uint32 dir,Uint8 plus) { Object*o; Object*q; Uint32 n; Value v; if(StackProtection()) Throw("Call stack overflow during movement"); if(obj==VOIDLINK) return 0; o=objects[obj]; if(o->oflags&(OF_DESTROYED|OF_BIZARRO)) return 0; dir=resolve_dir(obj,dir); if(plus) { if(o->oflags&OF_MOVING) { if(o->dir==dir) return 1; v=send_message(VOIDLINK,obj,MSG_CONFLICT,NVALUE(dir),NVALUE(0),NVALUE(0)); if(!v_bool(v)) return 0; } o->oflags|=OF_MOVING; o->dir=dir; } else { if(!(o->oflags&OF_MOVING)) return 0; if(o->dir!=dir) return 0; o->oflags&=~OF_MOVING; } n=playfield[o->x+o->y*64-65]; while(n!=VOIDLINK) { q=objects[n]; if(!(q->oflags&(OF_DESTROYED|OF_VISUALONLY)) && ((q->height>0 && q->height>=o->climb) || (classes[q->class]->collisionLayers&classes[o->class]->collisionLayers))) { v=send_message(obj,n,MSG_BLOCKED,NVALUE(o->x),NVALUE(o->y),NVALUE(plus)); if(v.t) Throw("Type mismatch"); if(v.u&1) o->oflags&=~OF_MOVING; if(v.u&2) break; } n=q->up; } return plus?(o->oflags&OF_MOVING?1:0):1; } static void trace_stack(Uint32 obj) { Value t2=Pop(); Value t1=Pop(); Value t0=Pop(); Object*o; if(!main_options['t']) return; |
︙ | |||
1066 1067 1068 1069 1070 1071 1072 | 1103 1104 1105 1106 1107 1108 1109 1110 1111 1112 1113 1114 1115 1116 1117 1118 1119 1120 1121 1122 1123 1124 1125 1126 1127 1128 1129 1130 | - + - + | printf(" : %u %u [$%s %d %d]",o->generation,obj,classes[o->class]->name,o->x,o->y); printf(" : %u %u : %u %u\n",t1.t,t1.u,t2.t,t2.u); } static void flush_object(Uint32 n) { Object*o=objects[n]; o->arrived=o->departed=0; |
︙ | |||
1438 1439 1440 1441 1442 1443 1444 1445 1446 1447 1448 1449 1450 1451 | 1475 1476 1477 1478 1479 1480 1481 1482 1483 1484 1485 1486 1487 1488 1489 1490 1491 1492 1493 1494 1495 1496 1497 1498 1499 1500 1501 1502 1503 1504 1505 1506 1507 1508 | + + + + + + + + + + + + + + + + + + + + | p++; for(n=0;n<(vstackptr-p)/2;n++) { v=vstack[p+n]; vstack[p+n]=vstack[vstackptr-n-1]; vstack[vstackptr-n-1]=v; } } static inline void v_obj_moving_to(Uint32 x,Uint32 y) { int d; Uint32 n,xx,yy; Object*o; for(d=0;d<8;d++) { xx=x-x_delta[d]; yy=y-y_delta[d]; if(xx<1 || xx>pfwidth || yy<1 || yy>pfheight) continue; n=playfield[xx+yy*64-65]; while(n!=VOIDLINK) { o=objects[n]; if((o->oflags&OF_MOVING) && !(o->oflags&(OF_DESTROYED|OF_VISUALONLY)) && o->dir==d) { if(vstackptr>=VSTACKSIZE-2) Throw("Stack overflow"); Push(OVALUE(n)); } n=o->up; } } } // Here is where the execution of a Free Hero Mesh bytecode subroutine is executed. #define NoIgnore() do{ changed=1; }while(0) #define GetVariableOf(a,b) (i=v_object(Pop()),i==VOIDLINK?NVALUE(0):b(objects[i]->a)) #define GetVariableOrAttributeOf(a,b) (t2=Pop(),t2.t==TY_CLASS?NVALUE(classes[t2.u]->a):(i=v_object(t2),i==VOIDLINK?NVALUE(0):b(objects[i]->a))) #define Numeric(a) do{ if((a).t!=TY_NUMBER) Throw("Type mismatch"); }while(0) #define DivideBy(a) do{ Numeric(a); if(!(a).u) Throw("Division by zero"); }while(0) |
︙ | |||
1671 1672 1673 1674 1675 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 1704 1705 1706 1707 1708 1709 1710 1711 1712 1713 1714 1715 1716 1717 1718 1719 1720 1721 1722 1723 1724 1725 1726 1727 1728 | 1728 1729 1730 1731 1732 1733 1734 1735 1736 1737 1738 1739 1740 1741 1742 1743 1744 1745 1746 1747 1748 1749 1750 1751 1752 1753 1754 1755 1756 1757 1758 1759 1760 1761 1762 1763 1764 1765 1766 1767 1768 1769 1770 1771 1772 1773 1774 1775 1776 1777 1778 1779 1780 1781 1782 1783 1784 1785 1786 1787 1788 1789 1790 1791 1792 1793 1794 1795 1796 1797 1798 | + + + + + + + + + + + + + | case OP_LT: StackReq(2,1); t2=Pop(); t1=Pop(); Push(NVALUE(v_unsigned_greater(t2,t1)?1:0)); break; case OP_LT_C: StackReq(2,1); t2=Pop(); t1=Pop(); Push(NVALUE(v_signed_greater(t2,t1)?1:0)); break; case OP_LXOR: StackReq(2,1); t1=Pop(); t2=Pop(); if(v_bool(t1)?!v_bool(t2):v_bool(t2)) Push(NVALUE(1)); else Push(NVALUE(0)); break; case OP_MANHATTAN: StackReq(1,1); t1=Pop(); i=manhattan(obj,v_object(t1)); Push(NVALUE(i)); break; case OP_MANHATTAN_C: StackReq(2,1); t2=Pop(); t1=Pop(); i=manhattan(v_object(t1),v_object(t2)); Push(NVALUE(i)); break; case OP_MARK: StackReq(0,1); Push(UVALUE(0,TY_MARK)); break; case OP_MAXINVENTORY: StackReq(1,0); t1=Pop(); Numeric(t1); if(ninventory>t1.u) Throw("Inventory overflow"); break; case OP_MINUSMOVE: StackReq(1,1); t1=Pop(); Numeric(t1); i=defer_move(obj,t1.u,0); Push(NVALUE(i)); break; case OP_MINUSMOVE_C: StackReq(2,1); t1=Pop(); Numeric(t1); i=v_object(Pop()); i=defer_move(i,t1.u,0); Push(NVALUE(i)); break; case OP_MINUSMOVE_D: StackReq(1,0); t1=Pop(); Numeric(t1); defer_move(obj,t1.u,0); break; case OP_MINUSMOVE_CD: StackReq(2,1); t1=Pop(); Numeric(t1); i=v_object(Pop()); defer_move(i,t1.u,0); break; case OP_MOD: StackReq(2,1); t2=Pop(); DivideBy(t2); t1=Pop(); Numeric(t1); Push(NVALUE(t1.u%t2.u)); break; case OP_MOD_C: StackReq(2,1); t2=Pop(); DivideBy(t2); t1=Pop(); Numeric(t1); Push(NVALUE(t1.s%t2.s)); break; case OP_MOVE: NoIgnore(); StackReq(1,1); t1=Pop(); Numeric(t1); o->inertia=o->strength; Push(NVALUE(move_dir(obj,obj,t1.u))); break; case OP_MOVE_C: NoIgnore(); StackReq(2,1); t1=Pop(); Numeric(t1); i=v_object(Pop()); if(i==VOIDLINK) Push(NVALUE(0)); else { objects[i]->inertia=o->strength; Push(NVALUE(move_dir(obj,i,t1.u))); } break; case OP_MOVE_D: NoIgnore(); StackReq(1,0); t1=Pop(); Numeric(t1); o->inertia=o->strength; move_dir(obj,obj,t1.u); break; case OP_MOVE_CD: NoIgnore(); StackReq(2,0); t1=Pop(); Numeric(t1); i=v_object(Pop()); if(i!=VOIDLINK) { objects[i]->inertia=o->strength; move_dir(obj,i,t1.u); } break; case OP_MOVED: StackReq(0,1); if(o->oflags&OF_MOVED) Push(NVALUE(1)); else Push(NVALUE(0)); break; case OP_MOVED_C: StackReq(1,1); GetFlagOf(OF_MOVED); break; case OP_MOVED_E: NoIgnore(); StackReq(1,0); if(v_bool(Pop())) o->oflags|=OF_MOVED; else o->oflags&=~OF_MOVED; break; case OP_MOVED_EC: NoIgnore(); StackReq(2,0); SetFlagOf(OF_MOVED); break; case OP_MOVENUMBER: StackReq(0,1); Push(NVALUE(move_number)); break; case OP_MOVEPLUS: NoIgnore(); StackReq(1,1); t1=Pop(); Numeric(t1); o->inertia+=o->strength; Push(NVALUE(move_dir(obj,obj,t1.u))); break; case OP_MOVEPLUS_C: NoIgnore(); StackReq(2,1); t1=Pop(); Numeric(t1); i=v_object(Pop()); if(i==VOIDLINK) Push(NVALUE(0)); else {objects[i]->inertia+=o->strength;Push(NVALUE(move_dir(obj,i,t1.u)));} break; case OP_MOVEPLUS_D: NoIgnore(); StackReq(1,0); t1=Pop(); Numeric(t1); o->inertia+=o->strength; move_dir(obj,obj,t1.u); break; case OP_MOVEPLUS_CD: NoIgnore(); StackReq(2,0); t1=Pop(); Numeric(t1); i=v_object(Pop()); if(i!=VOIDLINK) { objects[i]->inertia+=o->strength; move_dir(obj,i,t1.u); } break; case OP_MOVETO: NoIgnore(); StackReq(2,1); t3=Pop(); Numeric(t3); t2=Pop(); Numeric(t2); Push(NVALUE(move_to(obj,obj,t2.u,t3.u))); break; case OP_MOVETO_C: NoIgnore(); StackReq(3,1); t3=Pop(); Numeric(t3); t2=Pop(); Numeric(t2); i=v_object(Pop()); Push(NVALUE(move_to(obj,i,t2.u,t3.u))); break; case OP_MOVETO_D: NoIgnore(); StackReq(2,0); t3=Pop(); Numeric(t3); t2=Pop(); Numeric(t2); move_to(obj,obj,t2.u,t3.u); break; case OP_MOVETO_CD: NoIgnore(); StackReq(3,0); t3=Pop(); Numeric(t3); t2=Pop(); Numeric(t2); i=v_object(Pop()); move_to(obj,i,t2.u,t3.u); break; case OP_MOVING: StackReq(0,1); if(o->oflags&OF_MOVING) Push(NVALUE(1)); else Push(NVALUE(0)); break; case OP_MOVING_C: StackReq(1,1); GetFlagOf(OF_MOVING); break; case OP_MOVING_E: NoIgnore(); StackReq(1,0); if(v_bool(Pop())) o->oflags|=OF_MOVING; else o->oflags&=~OF_MOVING; break; case OP_MOVING_EC: NoIgnore(); StackReq(2,0); SetFlagOf(OF_MOVING); break; case OP_MSG: StackReq(0,1); Push(MVALUE(msgvars.msg)); break; case OP_MUL: StackReq(2,1); t2=Pop(); Numeric(t2); t1=Pop(); Numeric(t1); Push(NVALUE(t1.u*t2.u)); break; case OP_MUL_C: StackReq(2,1); t2=Pop(); Numeric(t2); t1=Pop(); Numeric(t1); Push(NVALUE(t1.s*t2.s)); break; case OP_NE: StackReq(2,1); t2=Pop(); t1=Pop(); Push(NVALUE(v_equal(t1,t2)?0:1)); break; case OP_NEG: StackReq(1,1); t1=Pop(); Numeric(t1); t1.s=-t1.s; Push(t1); break; case OP_NEWX: StackReq(2,1); t2=Pop(); Numeric(t2); t1=Pop(); Numeric(t1); Push(NVALUE(new_x(t1.u,t2.u))); break; case OP_NEWXY: StackReq(3,1); t3=Pop(); Numeric(t3); t2=Pop(); Numeric(t2); t1=Pop(); Numeric(t1); Push(NVALUE(new_x(t1.u,t3.u))); Push(NVALUE(new_y(t2.u,t3.u))); break; case OP_NEWY: StackReq(2,1); t2=Pop(); Numeric(t2); t1=Pop(); Numeric(t1); Push(NVALUE(new_y(t1.u,t2.u))); break; case OP_NEXT: StackReq(0,1); ptr=v_next(code,ptr); break; case OP_NIN: StackReq(2,1); i=v_in(); Push(NVALUE(i?0:1)); break; case OP_NIP: StackReq(2,1); t1=Pop(); Pop(); Push(t1); break; case OP_OBJABOVE: StackReq(0,1); i=obj_above(obj); Push(OVALUE(i)); break; case OP_OBJABOVE_C: StackReq(1,1); i=obj_above(v_object(Pop())); Push(OVALUE(i)); break; case OP_OBJBELOW: StackReq(0,1); i=obj_below(obj); Push(OVALUE(i)); break; case OP_OBJBELOW_C: StackReq(1,1); i=obj_below(v_object(Pop())); Push(OVALUE(i)); break; case OP_OBJBOTTOMAT: StackReq(2,1); t2=Pop(); Numeric(t2); t1=Pop(); Numeric(t1); i=obj_bottom_at(t1.u,t2.u); Push(OVALUE(i)); break; case OP_OBJCLASSAT: StackReq(3,1); t3=Pop(); t2=Pop(); t1=Pop(); Push(v_obj_class_at(t1,t2,t3)); break; case OP_OBJDIR: StackReq(1,1); t2=Pop(); Numeric(t2); i=obj_dir(obj,t2.u); Push(OVALUE(i)); break; case OP_OBJDIR_C: StackReq(2,1); t2=Pop(); Numeric(t2); i=obj_dir(v_object(Pop()),t2.u); Push(OVALUE(i)); break; case OP_OBJLAYERAT: StackReq(3,1); t3=Pop(); Numeric(t3); t2=Pop(); Numeric(t2); t1=Pop(); Numeric(t1); i=obj_layer_at(t1.u,t2.u,t3.u); Push(OVALUE(i)); break; case OP_OBJMOVINGTO: StackReq(2,0); t2=Pop(); Numeric(t2); t1=Pop(); Numeric(t1); v_obj_moving_to(t1.u,t2.u); break; case OP_OBJTOPAT: StackReq(2,1); t2=Pop(); Numeric(t2); t1=Pop(); Numeric(t1); i=obj_top_at(t1.u,t2.u); Push(OVALUE(i)); break; case OP_OVER: StackReq(2,3); t2=Pop(); t1=Pop(); Push(t1); Push(t2); Push(t1); break; case OP_PICK: StackReq(0,1); t1=Pop(); Numeric(t1); if(t1.u>=vstackptr) Throw("Stack index out of range"); t1=vstack[vstackptr-t1.u-1]; Push(t1); break; case OP_PLAYER: StackReq(0,1); if(classes[o->class]->cflags&CF_PLAYER) Push(NVALUE(1)); else Push(NVALUE(0)); break; case OP_PLAYER_C: StackReq(1,1); GetClassFlagOf(CF_PLAYER); break; case OP_PLUSMOVE: StackReq(1,1); t1=Pop(); Numeric(t1); i=defer_move(obj,t1.u,1); Push(NVALUE(i)); break; case OP_PLUSMOVE_C: StackReq(2,1); t1=Pop(); Numeric(t1); i=v_object(Pop()); i=defer_move(i,t1.u,1); Push(NVALUE(i)); break; case OP_PLUSMOVE_D: StackReq(1,0); t1=Pop(); Numeric(t1); defer_move(obj,t1.u,1); break; case OP_PLUSMOVE_CD: StackReq(2,1); t1=Pop(); Numeric(t1); i=v_object(Pop()); defer_move(i,t1.u,1); break; case OP_POPUP: StackReq(1,0); v_set_popup(obj,0); break; case OP_POPUPARGS: i=code[ptr++]; StackReq(i+1,0); v_set_popup(obj,i); break; case OP_QA: StackReq(1,1); t1=Pop(); NotSound(t1); if(t1.t==TY_ARRAY) Push(NVALUE(1)); else Push(NVALUE(0)); break; case OP_QC: StackReq(1,1); t1=Pop(); NotSound(t1); if(t1.t==TY_CLASS) Push(NVALUE(1)); else Push(NVALUE(0)); break; case OP_QCZ: StackReq(1,1); t1=Pop(); NotSound(t1); if(t1.t==TY_CLASS || (t1.t==TY_NUMBER && !t1.u)) Push(NVALUE(1)); else Push(NVALUE(0)); break; case OP_QM: StackReq(1,1); t1=Pop(); NotSound(t1); if(t1.t==TY_MESSAGE) Push(NVALUE(1)); else Push(NVALUE(0)); break; case OP_QN: StackReq(1,1); t1=Pop(); NotSound(t1); if(t1.t==TY_NUMBER) Push(NVALUE(1)); else Push(NVALUE(0)); break; |
︙ | |||
1937 1938 1939 1940 1941 1942 1943 1944 1945 1946 1947 1948 1949 1950 | 2007 2008 2009 2010 2011 2012 2013 2014 2015 2016 2017 2018 2019 2020 2021 2022 2023 2024 2025 2026 2027 2028 2029 2030 2031 2032 2033 2034 2035 2036 2037 2038 2039 2040 2041 2042 2043 2044 2045 2046 2047 2048 2049 2050 2051 2052 2053 2054 2055 2056 2057 2058 2059 2060 2061 2062 2063 2064 2065 2066 2067 2068 2069 2070 2071 2072 2073 2074 2075 2076 2077 2078 2079 2080 2081 2082 2083 2084 2085 2086 2087 2088 2089 2090 2091 2092 2093 2094 2095 2096 2097 2098 2099 2100 2101 2102 2103 2104 2105 2106 2107 2108 2109 2110 2111 2112 2113 2114 2115 2116 2117 2118 2119 2120 2121 2122 2123 2124 2125 2126 2127 2128 2129 2130 | + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + | clear_inventory(); for(i=0;i<nlevelstrings;i++) free(levelstrings[i]); nlevelstrings=0; free(deadanim); deadanim=0; ndeadanim=0; } static inline int try_sharp(Uint32 n1,Uint32 n2) { Object*o=objects[n1]; Object*p=objects[n2]; if((o->oflags|p->oflags)&OF_DESTROYED) return 0; if(o->dir&1) return 0; if(p->x!=o->x+x_delta[o->dir] || p->y!=o->y+y_delta[o->dir]) return 0; if(p->hard[(o->dir^4)>>1]<=o->sharp[o->dir>>1]) return 0; return !v_bool(destroy(n1,n2,o->oflags&OF_MOVING?2:1)); } static Uint32 handle_colliding(Uint32 n1,Uint32 n2,Uint8 r1,Uint8 r2) { // n1 = the object trying to move // n2 = the object it is colliding with (which might also be trying to move, or might not) Value v; Uint32 h; v=send_message(n1,n2,MSG_COLLIDING,NVALUE(objects[n1]->x),NVALUE(objects[n1]->y),NVALUE(r1)); if(v.t) Throw("Type mismatch"); h=(v.u>>16)|(v.u<<16); v=send_message(n2,n1,MSG_COLLIDING,NVALUE(objects[n2]->x),NVALUE(objects[n2]->y),NVALUE(r2)); if(v.t) Throw("Type mismatch"); h|=v.u; if((h&0x0002) && try_sharp(n1,n2)) h|=0x0004; if((h&0x00020000) && try_sharp(n2,n1)) h|=0x00040000; return h; } static Uint32 deferred_colliding(Uint32 obj,int x,int y) { Object*o=objects[obj]; Object*oE; Uint32 h=0xFFFFFFFF; Uint32 objE=playfield[x+y*64-65]; Uint8 d; int xx,yy; while(objE!=VOIDLINK) { oE=objects[objE]; if(!(oE->oflags&(OF_DESTROYED|OF_VISUALONLY))) { if(oE->oflags&OF_MOVING) { // At this point, it is necessary to check for a loop, which may be like the diagram below: // >>>>>>>v // ^<<<< // The loop may also have a different shape. // If a loop is found, call the handle_colliding function to determine what to do next. // If there is no loop, allow the move to be retried later, trying objE's location next. } if(oE->height>o->climb || (classes[o->class]->collisionLayers&classes[oE->class]->collisionLayers)) { h&=handle_colliding(obj,objE,1,0); } } objE=oE->up; } // Find other objects trying to move to the same place if(h&8) for(d=0;d<8;d++) { xx=x-x_delta[d]; yy=y-y_delta[d]; if(xx<1 || xx>pfwidth || yy<1 || yy>pfheight) continue; objE=playfield[xx+yy*64-65]; while(objE!=VOIDLINK) { oE=objects[objE]; if(obj!=objE && (oE->oflags&OF_MOVING) && oE->dir==d && !(oE->oflags&OF_DESTROYED)) { if(o->height>oE->climb || oE->height>o->climb || (classes[o->class]->collisionLayers&classes[oE->class]->collisionLayers)) { h&=handle_colliding(obj,objE,2,2); } } objE=oE->up; } } return ~h; } static void do_deferred_moves(void) { Object*o; Object*p; Uint32 h,n; int i,x,y; Uint8 re; restart: re=0; for(i=0;i<64*pfheight;i++) { retry: n=playfield[i]; while(n!=VOIDLINK) { o=objects[n]; if((o->oflags&(OF_MOVING|OF_DESTROYED))==OF_MOVING) { x=o->x+x_delta[o->dir]; y=o->y+y_delta[o->dir]; if(x<1 || x>pfwidth || y<1 || y>pfheight || playfield[x+y*64-65]==VOIDLINK) goto stop; h=deferred_colliding(n,x,y); if((h&1) && (o->oflags&OF_MOVING) && move_to(VOIDLINK,n,x,y)) { re=1; o->oflags=(o->oflags|OF_MOVED)&~OF_MOVING; i-=65; if(i<0) i=0; goto retry; } stop: if(!(h&4)) o->oflags&=~OF_MOVING; } skip: n=o->up; } } if(re) goto restart; } static void execute_animation(Uint32 obj) { Object*o=objects[obj]; Animation*a=o->anim; if(!(a->step[a->lstep].flag&ANI_ONCE)) return; if(a->ltime>=a->step[a->lstep].speed) { a->ltime=0; |
︙ | |||
1986 1987 1988 1989 1990 1991 1992 | 2166 2167 2168 2169 2170 2171 2172 2173 2174 2175 2176 2177 2178 2179 2180 | - + | all_flushed=0; lastimage_processing=0; vstackptr=0; current_key=key; tc=0; for(n=0;n<nobjects;n++) if(o=objects[n]) { o->distance=0; |
︙ | |||
2057 2058 2059 2060 2061 2062 2063 2064 2065 2066 2067 2068 2069 2070 | 2237 2238 2239 2240 2241 2242 2243 2244 2245 2246 2247 2248 2249 2250 2251 2252 2253 2254 | + + + + | send_message(VOIDLINK,n,MSG_ARRIVED,NVALUE(0),NVALUE(0),NVALUE(turn)); o->arrived=0; busy=1; } if(o->anim && (o->anim->status&ANISTAT_LOGICAL)) execute_animation(n); if(o->oflags&(OF_BUSY|OF_USERSIGNAL)) busy=1; } else { if(o->oflags&OF_MOVING) { do_deferred_moves(); goto trig; } o->departed2|=o->departed; o->arrived2|=o->arrived; o->departed=o->arrived=0; if(o->oflags&OF_MOVED) o->oflags=(o->oflags|OF_MOVED2)&~OF_MOVED; } n=m; } |
︙ | |||
2085 2086 2087 2088 2089 2090 2091 | 2269 2270 2271 2272 2273 2274 2275 2276 2277 2278 2279 2280 2281 2282 2283 2284 2285 2286 2287 2288 2289 2290 2291 2292 2293 2294 2295 2296 2297 2298 2299 2300 2301 2302 2303 2304 | - + - + | } // Ending phase if(!busy && !all_flushed) { n=lastobj; while(n!=VOIDLINK) { v=send_message(VOIDLINK,n,MSG_END_TURN,NVALUE(turn),NVALUE(0),NVALUE(0)); if(v_bool(v) || objects[n]->arrived || objects[n]->departed) busy=1; |
︙ |
Modified heromesh.h from [c3de22e2d5] to [7ea394ee1c].
︙ | |||
33 34 35 36 37 38 39 | 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 | - + | #define CVALUE(x) UVALUE(x,TY_CLASS) #define MVALUE(x) UVALUE(x,TY_MESSAGE) #define ZVALUE(x) UVALUE(x,TY_STRING) #define OVALUE(x) ((x)==VOIDLINK?NVALUE(0):UVALUE(x,objects[x]->generation)) #define ValueTo64(v) (((sqlite3_int64)((v).u))|(((sqlite3_int64)((v).t))<<32)) #define ValueEq(x,y) ((x).t==(y).t && (x).u==(y).u) |
︙ | |||
135 136 137 138 139 140 141 142 143 144 145 146 147 148 | 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 | + | #define OF_USERSIGNAL 0x0020 #define OF_MOVED 0x0040 #define OF_DONE 0x0080 #define OF_KEYCLEARED 0x0100 #define OF_DESTROYED 0x0200 #define OF_BIZARRO 0x0400 #define OF_MOVED2 0x0800 #define OF_MOVING 0x1000 typedef struct { const char*name; const char*edithelp; // not present if CF_GROUP const char*gamehelp; // not present if CF_GROUP Uint16*codes; // if this is CF_GROUP, then instead a zero-terminated list of classes Uint16*messages; // use 0xFFFF if no such message block; not present if CF_GROUP |
︙ |
Modified instruc from [0d803850a1] to [e27eafbe67].
︙ | |||
170 171 172 173 174 175 176 177 178 179 180 181 182 183 | 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 | + | ,=Invisible ,=KeyCleared ,=UserSignal ,=UserState ,=VisualOnly ,=Stealthy ,=Moved ,=Moving ,=Done ,Destroyed ,Player ,Compatible ,CollisionLayers Self Msg |
︙ | |||
226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 | 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 | + + + | LocateMe LoseLevel ,Manhattan MaxInventory ; error if more than that many slots in inventory .,Move .,MovePlus "Move+" ; obj.Inertia+=Strength instead of obj.Inertia=Strength .,MoveTo ; the internal MoveTo() function .,PlusMove "+Move" .,MinusMove "-Move" NewX NewXY NewY ,ObjAbove ,ObjBelow ObjBottomAt ObjClassAt ,ObjDir ObjLayerAt ObjMovingTo ObjTopAt PopUp *PopUpArgs ; for (PopUp [number]) ,Rel ,Seek .,Send .,SendEx ; send with three arguments |
︙ |
Modified instruc.h from [6d4bc1a2f8] to [9467248115].
︙ | |||
243 244 245 246 247 248 249 | 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 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 396 397 398 399 400 401 402 403 404 405 406 407 408 409 410 411 412 413 414 415 416 417 418 419 420 421 422 423 424 425 426 427 428 429 430 431 432 433 434 435 436 437 438 439 440 441 442 443 444 445 446 447 448 449 450 451 452 453 454 455 456 457 458 459 460 461 462 463 464 465 466 467 468 469 470 471 472 473 474 475 476 477 478 479 480 481 482 483 484 485 486 487 488 489 490 491 492 493 494 495 496 497 498 499 500 501 502 503 504 505 506 507 508 509 510 511 512 513 514 515 516 517 518 519 520 521 522 523 524 525 526 527 528 529 530 531 532 533 534 535 536 537 538 539 540 541 542 543 544 545 546 547 548 549 550 551 552 553 554 555 556 557 558 559 560 561 562 563 564 565 566 567 568 569 570 571 572 573 574 575 576 577 578 579 580 581 582 583 584 585 586 587 588 589 590 591 592 593 594 595 596 597 598 599 600 601 602 603 604 605 606 607 608 609 610 611 612 613 614 615 616 617 618 619 620 621 622 623 624 625 626 627 628 629 630 631 632 633 634 635 636 637 638 639 640 641 | + + + + - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + - - - - - - - + + + + + + + - + - + - - - - - + + + + + - + + - + - - - + + + - - - + + + - - + + - + - + - - - - + + + + - - + + - - + + - + - + - - - + + + - + - + - - - - + + + + - - + + - - - - + + + + + - + - - - + + + - - - - - - - + + + + + + + + - - - + + + - + - + - - - - - - + + + + + + - + - + - + - + - - - + + + - + - + | #define OP_STEALTHY_C 34923 #define OP_STEALTHY_E 36971 #define OP_STEALTHY_EC 39019 #define OP_MOVED 32876 #define OP_MOVED_C 34924 #define OP_MOVED_E 36972 #define OP_MOVED_EC 39020 #define OP_MOVING 32877 #define OP_MOVING_C 34925 #define OP_MOVING_E 36973 #define OP_MOVING_EC 39021 |
︙ | |||
651 652 653 654 655 656 657 | 669 670 671 672 673 674 675 676 677 678 679 680 681 682 683 684 685 686 687 688 689 690 691 692 693 694 695 696 697 698 699 700 701 702 703 704 705 706 707 708 709 710 711 712 713 714 715 716 717 718 719 720 721 722 | - + - + - + - + - + - + - + | {"bit7",8388736}, {"bit8",8423400}, {"bit9",8423401}, {"bnot",8421410}, {"bor",8421408}, {"bxor",8421409}, {"c?",8421424}, |
Modified names.h from [af89837265] to [76542780c7].
︙ | |||
15 16 17 18 19 20 21 | 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 | - + + - + | #define MSG_PLAYERMOVING 13 #define MSG_HIT 14 #define MSG_HITBY 15 #define MSG_DESTROYED 16 #define MSG_CREATED 17 #define MSG_POSTINIT 18 #define MSG_END_TURN 19 |
︙ | |||
41 42 43 44 45 46 47 | 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 | - + + - + | "PLAYERMOVING", "HIT", "HITBY", "DESTROYED", "CREATED", "POSTINIT", "END_TURN", |
︙ |
Modified names.js from [d593430889] to [528389457e].
︙ | |||
20 21 22 23 24 25 26 | 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 | - + - + + | 14 = HIT 15 = HITBY 16 = DESTROYED 17 = CREATED 18 = POSTINIT 19 = END_TURN // New |
︙ |