Example #1
0
    bool set_map(const types::String& id)
    {
        generate_scenario_code();

#ifdef SERVER
        send_PrepareForNewScenario(-1, scenario_code.get_buf());
        force_network_flush();
#endif

        curr_map_id = id;

        types::String s = id.substr(0, id.length() - 7);
        s += "/map";

        if (!load_world(s.get_buf()))
        {
            logger::log(logger::ERROR, "Failed to load world!\n");
            return false;
        }

#ifdef SERVER
        server::createluaEntity(-1);
        send_curr_map(-1);
#else
        send_RequestPrivateEditMode();
#endif

        return true;
    }
Example #2
0
    bool set_map(const char *id) {
        generate_scenario_code();

#ifdef SERVER
        send_PrepareForNewScenario(-1, scenario_code);
        force_network_flush();
#endif

        copystring(curr_map_id, id);

        string buf;
        copystring(buf, id);
        int len = strlen(id);
        assert(len > 7);
        memcpy(buf + len - 7, "/map", 5);

        if (!load_world(buf)) {
            logger::log(logger::ERROR, "Failed to load world!\n");
            return false;
        }

#ifdef SERVER
        /* always returns false with -1 - no pop needed */
        server::createluaEntity(-1);
        send_curr_map(-1);
#else
        send_RequestPrivateEditMode();
#endif

        return true;
    }