#include "autoconf.h" #include "dclient/client.h" #include "dclient/input_handler.h" #include "dclient/query_handler.h" #include "dclient/renderer.h" #include "dclient/widgets.h" #include "dclient/widgets/inventory.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 ) { struct ev_loop *loop = ev_default_loop (EVBACKEND_SELECT); // ncurses setlocale (LC_ALL, ""); std::auto_ptr app (ndk::app = new ndk::application); app->init_palette (); // deliantra communicator comm (server, port); command_parser cmdp; handshake_handler hh (comm); message_logger logger; inventory_manager invman; // dclient client cli (comm, cmdp); widgets ui; renderer rend (ui); input_handler input (comm, ui); query_handler qh (comm, ui, user, pass); // link them all together invman.set_inventory_view (*ui.inventory); invman.set_container_view (*ui.container); comm.set_packet_handler (cli); cmdp.add_command_handler (hh); cmdp.add_command_handler (qh); cmdp.add_command_handler (invman); cmdp.add_command_handler (rend); cmdp.add_command_handler (logger); // run the event loop ev_run (loop, 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; }