void AllTextures::Parse_textureMap(std::istream &is) { std::string line; std::string scriptPath; Tim::String::get_line(is, line, true, true); if (line == "ScriptPath:") { Tim::String::get_line(is, line, true, true); scriptPath = std::string(line); TextureMap* map=new TextureMap(folder_path+scriptPath); push_map(map); } }
/** * \brief Implementation of item:get_map(). * \param l The Lua context that is calling this function. * \return Number of values to return to Lua. */ int LuaContext::item_api_get_map(lua_State* l) { EquipmentItem& item = check_item(l, 1); Game* game = item.get_game(); if (game != NULL) { push_map(l, game->get_current_map()); } else { lua_pushnil(l); } return 1; }
/** * \brief Implementation of game:get_map(). * \param l The Lua context that is calling this function. * \return Number of values to return to Lua. */ int LuaContext::game_api_get_map(lua_State* l) { Savegame& savegame = check_game(l, 1); Game* game = savegame.get_game(); if (game == NULL || !game->has_current_map()) { lua_pushnil(l); } else { push_map(l, game->get_current_map()); } return 1; }
/** * \brief Implementation of sol.timer.start(). * \param l the Lua context that is calling this function * \return number of values to return to Lua */ int LuaContext::timer_api_start(lua_State *l) { return LuaTools::exception_boundary_handle(l, [&] { // Parameters: [context] delay callback. LuaContext& lua_context = get_lua_context(l); if (lua_type(l, 1) != LUA_TNUMBER) { // The first parameter is the context. if (lua_type(l, 1) != LUA_TTABLE && lua_type(l, 1) != LUA_TUSERDATA) { LuaTools::type_error(l, 1, "table or userdata"); } } else { // No context specified: set a default context: // - during a game: the current map, // - outside a game: sol.main. Game* game = lua_context.get_main_loop().get_game(); if (game != nullptr && game->has_current_map()) { push_map(l, game->get_current_map()); } else { LuaContext::push_main(l); } lua_insert(l, 1); } // Now the first parameter is the context. uint32_t delay = uint32_t(LuaTools::check_int(l, 2)); const ScopedLuaRef& callback_ref = LuaTools::check_function(l, 3); // Create the timer. TimerPtr timer = std::make_shared<Timer>(delay); lua_context.add_timer(timer, 1, callback_ref); if (delay == 0) { // The delay is zero: call the function right now. lua_context.do_timer_callback(timer); } push_timer(l, timer); return 1; }); }
/** * @brief Implementation of sol.timer.start(). * @param l the Lua context that is calling this function * @return number of values to return to Lua */ int LuaContext::timer_api_start(lua_State *l) { // Parameters: [context] delay callback. LuaContext& lua_context = get_lua_context(l); if (lua_type(l, 1) != LUA_TNUMBER) { // The first parameter is the context. if (lua_type(l, 1) != LUA_TTABLE && lua_type(l, 1) != LUA_TUSERDATA) { luaL_typerror(l, 1, "table or userdata"); } } else { // No context specified: set a default context: // - during a game: the current map, // - outside a game: sol.main. Game* game = lua_context.get_main_loop().get_game(); if (game != NULL) { push_map(l, game->get_current_map()); } else { LuaContext::push_main(l); } lua_insert(l, 1); } // Now the first parameter is the context. uint32_t delay = uint32_t(luaL_checkint(l, 2)); luaL_checktype(l, 3, LUA_TFUNCTION); if (delay == 0) { // The delay is zero: call the function right now. lua_settop(l, 3); lua_context.call_function(0, 0, "callback"); lua_pushnil(l); } else { // Create the timer. Timer* timer = new Timer(delay); lua_context.add_timer(timer, 1, 3); push_timer(l, *timer); } return 1; }
void gen_map(t_map **map, int width, int height) { int x; int y; y = height; write(1, "Generation de la map en cours...", 32); while (y > 0) { y--; x = width; while (x > 0) { x--; push_map(map, x, y); push_obj(&((*map)->objects), (e_id)((rand() % 8) - 1)); } } write(1, " Termine !\n", 11); }
bool run(struct context *context, struct byte_array *program, struct map *env, bool in_context) { null_check(context); null_check(program); program = byte_array_copy(program); program->current = program->data; struct program_state *state = NULL; enum Opcode inst = VM_NIL; if (context->runtime) { if (in_context) { if (!state) state = (struct program_state*)stack_peek(context->program_stack, 0); env = state->named_variables; // use the caller's variable set in the new state } else state = program_state_new(context, env); } while (program->current < program->data + program->length) { inst = (enum Opcode)*program->current; bool really = inst & VM_RLY; inst &= ~VM_RLY; #ifdef DEBUG display_program_counter(context, program); #endif program->current++; // increment past the instruction int32_t pc_offset = 0; switch (inst) { case VM_COM: case VM_ITR: if (iterate(context, inst, state, program)) goto done; break; case VM_RET: if (ret(context, program)) goto done; break; case VM_TRO: if (tro(context)) goto done; break; case VM_TRY: if (vm_trycatch(context, program)) goto done; break; case VM_EQU: case VM_MUL: case VM_DIV: case VM_ADD: case VM_SUB: case VM_NEQ: case VM_GTN: case VM_LTN: case VM_GRQ: case VM_LEQ: case VM_BND: case VM_BOR: case VM_MOD: case VM_XOR: case VM_INV: case VM_RSF: case VM_LSF: binary_op(context, inst); break; case VM_ORR: case VM_AND: pc_offset = boolean_op(context, program, inst); break; case VM_NEG: case VM_NOT: unary_op(context, inst); break; case VM_SRC: src(context, inst, program); break; case VM_DST: dst(context, really); break; case VM_STX: case VM_SET: set(context, inst, state, program); break; case VM_JMP: pc_offset = jump(context, program); break; case VM_IFF: pc_offset = iff(context, program); break; case VM_CAL: func_call(context, inst, program, NULL); break; case VM_LST: push_list(context, program); break; case VM_MAP: push_map(context, program); break; case VM_NIL: push_nil(context); break; case VM_INT: push_int(context, program); break; case VM_FLT: push_float(context, program); break; case VM_BUL: push_bool(context, program); break; case VM_STR: push_str(context, program); break; case VM_VAR: push_var(context, program); break; case VM_FNC: push_fnc(context, program); break; case VM_GET: list_get(context, really); break; case VM_PTX: case VM_PUT: list_put(context, inst, really); break; case VM_MET: method(context, program, really); break; default: vm_exit_message(context, ERROR_OPCODE); return false; } program->current += pc_offset; } if (!context->runtime) return false; done: if (!in_context) stack_pop(context->program_stack); return inst == VM_RET; }
bool CSeqMap_CI::x_Push(TSeqPos pos, bool resolveExternal) { const TSegmentInfo& info = x_GetSegmentInfo(); if ( !info.InRange() ) { return false; } const CSeqMap::CSegment& seg = info.x_GetSegment(); CSeqMap::ESegmentType type = CSeqMap::ESegmentType(seg.m_SegType); switch ( type ) { case CSeqMap::eSeqSubMap: {{ CConstRef<CSeqMap> push_map (static_cast<const CSeqMap*>(info.m_SeqMap->x_GetObject(seg))); // We have to copy the info.m_TSE into local variable push_tse because // of TSegmentInfo referenced by info can be moved inside x_Push() call. CTSE_Handle push_tse = info.m_TSE; x_Push(push_map, info.m_TSE, GetRefPosition(), GetLength(), GetRefMinusStrand(), pos); break; }} case CSeqMap::eSeqRef: {{ if ( !resolveExternal ) { return false; } const CSeq_id& seq_id = static_cast<const CSeq_id&>(*info.m_SeqMap->x_GetObject(seg)); CBioseq_Handle bh; if ( m_Selector.x_HasLimitTSE() ) { // Check TSE limit bh = m_Selector.x_GetLimitTSE().GetBioseqHandle(seq_id); if ( !bh ) { return false; } } else { if ( !GetScope() ) { NCBI_THROW(CSeqMapException, eNullPointer, "Cannot resolve "+ seq_id.AsFastaString()+": null scope pointer"); } bh = GetScope()->GetBioseqHandle(seq_id); if ( !bh ) { if ( GetFlags() & CSeqMap::fIgnoreUnresolved ) { return false; } NCBI_THROW(CSeqMapException, eFail, "Cannot resolve "+ seq_id.AsFastaString()+": unknown"); } } if ( (GetFlags() & CSeqMap::fByFeaturePolicy) && bh.GetFeatureFetchPolicy() == bh.eFeatureFetchPolicy_only_near ) { return false; } if ( info.m_TSE ) { if ( !info.m_TSE.AddUsedTSE(bh.GetTSE_Handle()) ) { m_Selector.AddUsedTSE(bh.GetTSE_Handle()); } } size_t depth = m_Stack.size(); x_Push(ConstRef(&bh.GetSeqMap()), bh.GetTSE_Handle(), GetRefPosition(), GetLength(), GetRefMinusStrand(), pos); if (m_Stack.size() == depth) { return false; } m_Selector.PushResolve(); if ( (m_Stack.size() & 63) == 0 ) { // check for self-recursion every 64'th stack frame const CSeqMap* top_seq_map = &m_Stack.back().x_GetSeqMap(); for ( int i = m_Stack.size()-2; i >= 0; --i ) { if ( &m_Stack[i].x_GetSeqMap() == top_seq_map ) { NCBI_THROW(CSeqMapException, eSelfReference, "Self-reference in CSeqMap"); } } } break; }} default: return false; } return true; }