// cat static inline void _vm_cat(struct a2_vm* vm_p){ struct a2_obj* _d = _getvalue(vm_p, ir_ga(curr_ir)); struct a2_obj* _lv = _getvalue(vm_p, ir_gb(curr_ir)); struct a2_obj* _rv = _getvalue(vm_p, ir_gc(curr_ir)); char buf[64] = {0}; char buf0[64] = {0}; char* a2_s = a2_string_new(obj2str(_lv, buf, sizeof(buf)-1)); a2_s = a2_string_cat(a2_s, obj2str(_rv, buf0, sizeof(buf0)-1)); obj_setX(_d, A2_TSTRING, obj, a2_env_addstrobj(vm_p->env_p, a2_s)); a2_string_free(a2_s); curr_pc++; }
//get global varable static inline void _vm_getglobal(struct a2_vm* vm_p){ int bx = ir_gbx(curr_ir); struct a2_obj* _dobj = callinfo_sfreg(curr_ci, ir_ga(curr_ir)); struct a2_obj* _k = _getvalue(vm_p, bx); struct a2_obj* _obj = a2_get_envglobal(vm_p->env_p, _k); if(_obj==NULL){ char _buf[64] = {0}; a2_error(vm_p->env_p, e_vm_error, "[vm error@%zd]: the global \'%s\' is not find.\n", curr_line, obj2str(_k, _buf, sizeof(_buf))); } *_dobj = *_obj; curr_pc++; }
/* Make a critter */ struct Critter *make_critter (ObjectType species, float x, float y, int owner) { struct Critter *newcritter = NULL; switch(species) { case OBJ_COW: newcritter = make_cow(x,y); break; case OBJ_SOLDIER: newcritter = make_soldier(x,y,owner); break; case OBJ_BIRD: newcritter = make_bird(x,y); break; case OBJ_BAT: newcritter = make_bat(x,y); break; case OBJ_HELICOPTER: newcritter = make_helicopter(x,y,owner); break; case OBJ_FISH: newcritter = make_fish(x,y); break; default: fprintf(stderr,"make_critter(%d,%.1f,%.1f,%d): Unhandled object type.\n",species, x, y, owner); } if(newcritter==NULL) return NULL; /* Find a place for the critter if not specified explicitly */ if (x < 0 || y < 0) { int medium,ground; if(newcritter->type==WATERCRITTER) { medium = TER_WATER; ground = 0; } else { medium = TER_FREE; if(newcritter->type==GROUNDCRITTER) ground=1; else if(species==OBJ_BAT) ground=-1; else ground=0; } if(random_coords(medium,ground,&newcritter->physics.x, &newcritter->physics.y)) { fprintf(stderr,"Couldn't find a place for a %s.\n", obj2str(species)); free (newcritter); return NULL; } } return newcritter; }