Implement the core of the login system
This commit is contained in:
@@ -81,7 +81,7 @@ void TextGame::do_view_command(const StringVec &cmd) {
|
||||
std::cerr << "v command (view) takes no arguments" << std::endl;
|
||||
return;
|
||||
}
|
||||
for (int64_t id : world_->get_near(1, 100, true)) {
|
||||
for (int64_t id : world_->get_near(actor_id_, 100, true)) {
|
||||
const Tangible *tan = world_->tangible_get(id);
|
||||
const AnimStep &aqback = tan->anim_queue_.back();
|
||||
std::cerr << id << ": " << aqback.graphic() << " " << aqback.plane() << " " << aqback.xyz() << std::endl;
|
||||
@@ -91,15 +91,15 @@ void TextGame::do_view_command(const StringVec &cmd) {
|
||||
void TextGame::do_menu_command(const StringVec &cmd) {
|
||||
int64_t id;
|
||||
if (cmd.size() == 1) {
|
||||
id = 1;
|
||||
id = actor_id_;
|
||||
} else if (cmd.size() == 2) {
|
||||
id = util::strtoint(cmd[1], -1);
|
||||
} else {
|
||||
std::cerr << "m command (menu) expects a tangible ID or defaults to 1" << std::endl;
|
||||
std::cerr << "m command (menu) expects a tangible ID or defaults to actor_id" << std::endl;
|
||||
return;
|
||||
}
|
||||
gui_place_ = id;
|
||||
world_->update_gui(1, id, &gui_);
|
||||
world_->update_gui(actor_id_, id, &gui_);
|
||||
int index = 0;
|
||||
for (const GuiElt &elt : gui_.elts()) {
|
||||
std::cerr << index << " " << elt.label() << std::endl;
|
||||
@@ -125,7 +125,7 @@ void TextGame::do_choose_command(const StringVec &cmd) {
|
||||
GuiResult dummyresult;
|
||||
dummyresult["flavor"] = "chocolate";
|
||||
dummyresult["color"] = "blue";
|
||||
world_->invoke_plan(1, gui_place_, action, dummyresult);
|
||||
world_->invoke_plan(actor_id_, gui_place_, action, dummyresult);
|
||||
}
|
||||
|
||||
void TextGame::do_snapshot_command(const StringVec &cmd) {
|
||||
@@ -164,12 +164,26 @@ void TextGame::do_command(const StringVec &words) {
|
||||
}
|
||||
}
|
||||
|
||||
void TextGame::check_redirects() {
|
||||
World::Redirects redir = world_->fetch_redirects();
|
||||
for (const auto &p : redir) {
|
||||
if (p.first == actor_id_) {
|
||||
actor_id_ = p.second;
|
||||
std::cerr << "Login actor ID: " << actor_id_ << std::endl;
|
||||
gui_.clear();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void TextGame::run()
|
||||
{
|
||||
world_.reset(new World);
|
||||
world_->init_standalone();
|
||||
actor_id_ = world_->create_login_actor();
|
||||
std::cerr << "Login actor ID: " << actor_id_ << std::endl;
|
||||
console_.clear();
|
||||
while (true) {
|
||||
check_redirects();
|
||||
console_.add_stdin();
|
||||
int action = console_.action();
|
||||
if (action == LuaConsole::DO_LUA) {
|
||||
|
||||
Reference in New Issue
Block a user