#include "autoconf.h" #include "tinput_handler.h" #include "tquery_handler.h" #include "trenderer.h" #include "deliantra/client.h" #include "deliantra/command_parser.h" #include "deliantra/communicator.h" #include "deliantra/handshake_handler.h" #include "deliantra/inventory_manager.h" #include "deliantra/message_logger.h" #include "deliantra/data/item.h" #include "adt/bind.h" #include #include #include #include #include static void start_game ( std::string const &server , std::string const &port , std::string const &user , std::string const &pass ) { if (!ev_default_loop (EVBACKEND_SELECT)) throw "unable to initialise event loop"; // deliantra communicator comm (server, port); command_parser cmdp; client cli (comm, cmdp); handshake_handler hh (comm); message_logger logger; inventory_manager invman; cmdp.add_command_handler (hh); //cmdp.add_command_handler (invman); cmdp.add_command_handler (logger); // link deliantra stuff together comm.set_packet_handler (cli); // tclient input_handler ih (comm); query_handler qh (comm, user, pass); renderer rend; // link tclient stuff in cmdp.add_command_handler (qh); cmdp.add_command_handler (rend); // run the event loop ev_run (EV_DEFAULT_UC_ 0); } int main (int argc, char *argv[]) try { if (argc == 2 && !strcmp (argv[1], "--version")) { printf ("%s version %s\n", PACKAGE_NAME, PACKAGE_VERSION); return EXIT_SUCCESS; } if (argc < 3 || !strcmp (argv[1], "--help")) { printf ("Usage: %s [user] [password]\n", PACKAGE); return EXIT_SUCCESS; } std::string server, port, user, pass; server = argv[1]; port = argv[2]; if (argc == 5) { user = argv[3]; pass = argv[4]; } start_game (server, port, user, pass); return EXIT_SUCCESS; } catch (std::exception const &e) { LOG ("exception") << e.what () << "\n"; printf ("exception caught: %s\n", e.what ()); return EXIT_FAILURE; } catch (int i) { LOG ("exception") << '0' << std::oct << std::setfill ('0') << std::setw (3) << i << "\n"; printf ("exception caught: 0%03o\n", i); return EXIT_FAILURE; } catch (std::string const &s) { LOG ("exception") << s << "\n"; printf ("exception caught: %s\n", s.c_str ()); return EXIT_FAILURE; } catch (char const *s) { LOG ("exception") << s << "\n"; printf ("exception caught: %s\n", s); return EXIT_FAILURE; } catch (...) { LOG ("exception"); puts ("exception caught"); return EXIT_FAILURE; }