dmn-commit Mailing List for DMN Modular Netgame (Page 3)
Status: Beta
Brought to you by:
xoseotero
You can subscribe to this list here.
| 2003 |
Jan
|
Feb
|
Mar
|
Apr
(6) |
May
(32) |
Jun
(64) |
Jul
(134) |
Aug
(124) |
Sep
(117) |
Oct
(91) |
Nov
(20) |
Dec
(62) |
|---|---|---|---|---|---|---|---|---|---|---|---|---|
| 2004 |
Jan
(10) |
Feb
|
Mar
(36) |
Apr
(23) |
May
(3) |
Jun
|
Jul
|
Aug
|
Sep
|
Oct
|
Nov
|
Dec
|
| 2005 |
Jan
(1) |
Feb
|
Mar
|
Apr
|
May
|
Jun
|
Jul
|
Aug
|
Sep
|
Oct
|
Nov
|
Dec
|
|
From: Xos? O. <xos...@us...> - 2004-03-17 04:58:18
|
Update of /cvsroot/dmn/dmn/dmn In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv7239/dmn Modified Files: config.h core.h display.h domino.h dominoes.h game.h hand.h id.h match.h module.cpp module.h moduleio.cpp moduleio.h msg.cpp msg.h player.h sound.h Log Message: Now all the code follow the coding style (doc/CodingStyle) Index: config.h =================================================================== RCS file: /cvsroot/dmn/dmn/dmn/config.h,v retrieving revision 1.1 retrieving revision 1.2 diff -u -d -r1.1 -r1.2 --- config.h 26 Dec 2003 20:40:04 -0000 1.1 +++ config.h 17 Mar 2004 04:48:23 -0000 1.2 @@ -60,7 +60,7 @@ * * @return true if all was ok, else false */ - virtual bool configure(int argc, char *argv[]) = 0; + virtual bool configure(int argc, char* argv[]) = 0; /** * Path to the module config to load Index: player.h =================================================================== RCS file: /cvsroot/dmn/dmn/dmn/player.h,v retrieving revision 1.1 retrieving revision 1.2 diff -u -d -r1.1 -r1.2 --- player.h 26 Dec 2003 20:09:11 -0000 1.1 +++ player.h 17 Mar 2004 04:48:23 -0000 1.2 @@ -57,7 +57,7 @@ * * @return true if all was ok, else false */ - virtual bool configure(Core *core) = 0; + virtual bool configure(Core* core) = 0; /** * Set the player's name @@ -95,7 +95,7 @@ * * @return true if the player pass or false if plays */ - virtual bool domino_to_play(Domino *domino, HalfDomino *half) = 0; + virtual bool domino_to_play(Domino* domino, HalfDomino* half) = 0; /** * Domino played by other player (no by the module) Index: module.h =================================================================== RCS file: /cvsroot/dmn/dmn/dmn/module.h,v retrieving revision 1.2 retrieving revision 1.3 diff -u -d -r1.2 -r1.3 --- module.h 29 Dec 2003 04:31:51 -0000 1.2 +++ module.h 17 Mar 2004 04:48:23 -0000 1.3 @@ -56,48 +56,6 @@ */ class Module { - private: - /** - * All modules have a unique identificator - */ - static IDs ids_; - ID id_; // Module identificator - - /* Module information */ - ModuleType type_; - std::string name_; - std::string version_; - std::string desc_; - - protected: - /** - * Set tye type of the module - * - * @param type The type of the module - */ - void set_type(ModuleType type = ModuleNONE); - - /** - * Set the name of the module - * - * @param name The name of the module - */ - void set_name(const std::string& name); - - /** - * Set the version of the module - * - * @param version The version of the module - */ - void set_version(const std::string& version); - - /** - * Description of the module - * - * @param desc The description of the module - */ - void set_desc(const std::string& desc); - public: /** * Constructor @@ -143,6 +101,48 @@ * @return The description of the module */ std::string desc() const; + + protected: + /** + * Set tye type of the module + * + * @param type The type of the module + */ + void set_type(ModuleType type = ModuleNONE); + + /** + * Set the name of the module + * + * @param name The name of the module + */ + void set_name(const std::string& name); + + /** + * Set the version of the module + * + * @param version The version of the module + */ + void set_version(const std::string& version); + + /** + * Description of the module + * + * @param desc The description of the module + */ + void set_desc(const std::string& desc); + + private: + /** + * All modules have a unique identificator + */ + static IDs ids_; + ID id_; // Module identificator + + /* Module information */ + ModuleType type_; + std::string name_; + std::string version_; + std::string desc_; }; }; Index: module.cpp =================================================================== RCS file: /cvsroot/dmn/dmn/dmn/module.cpp,v retrieving revision 1.1 retrieving revision 1.2 diff -u -d -r1.1 -r1.2 --- module.cpp 26 Dec 2003 20:09:11 -0000 1.1 +++ module.cpp 17 Mar 2004 04:48:23 -0000 1.2 @@ -47,47 +47,47 @@ ids_.destroy(id_); } -void Module::set_type(ModuleType type) +ID Module::id() const { - type_ = type; + return id_; } -void Module::set_name(const string& name) +ModuleType Module::type() const { - name_ = name; + return type_; } -void Module::set_version(const string& version) +string Module::name() const { - version_ = version; + return name_; } -void Module::set_desc(const string& desc) +string Module::version() const { - desc_ = desc; + return version_; } -ID Module::id() const +string Module::desc() const { - return id_; + return desc_; } -ModuleType Module::type() const +void Module::set_type(ModuleType type) { - return type_; + type_ = type; } -string Module::name() const +void Module::set_name(const string& name) { - return name_; + name_ = name; } -string Module::version() const +void Module::set_version(const string& version) { - return version_; + version_ = version; } -string Module::desc() const +void Module::set_desc(const string& desc) { - return desc_; + desc_ = desc; } Index: display.h =================================================================== RCS file: /cvsroot/dmn/dmn/dmn/display.h,v retrieving revision 1.1 retrieving revision 1.2 diff -u -d -r1.1 -r1.2 --- display.h 26 Dec 2003 20:09:11 -0000 1.1 +++ display.h 17 Mar 2004 04:48:23 -0000 1.2 @@ -58,7 +58,7 @@ * * @return true if all was ok, else false */ - virtual bool configure(Core *core) = 0; + virtual bool configure(Core* core) = 0; /** * Team winner of the tournament Index: msg.cpp =================================================================== RCS file: /cvsroot/dmn/dmn/dmn/msg.cpp,v retrieving revision 1.1 retrieving revision 1.2 diff -u -d -r1.1 -r1.2 --- msg.cpp 26 Dec 2003 20:09:11 -0000 1.1 +++ msg.cpp 17 Mar 2004 04:48:23 -0000 1.2 @@ -36,7 +36,7 @@ exit(exit_status); } -void Msg::error(int exit_status, char *fmt, ...) +void Msg::error(int exit_status, char* fmt, ...) { va_list ap; @@ -54,7 +54,7 @@ cerr << "Warning: " << str << endl; } -void Msg::warning(char *fmt, ...) +void Msg::warning(char* fmt, ...) { va_list ap; @@ -70,7 +70,7 @@ cerr << "Info: " << str << endl; } -void Msg::info(char *fmt, ...) +void Msg::info(char* fmt, ...) { va_list ap; Index: game.h =================================================================== RCS file: /cvsroot/dmn/dmn/dmn/game.h,v retrieving revision 1.1 retrieving revision 1.2 diff -u -d -r1.1 -r1.2 --- game.h 26 Dec 2003 20:09:11 -0000 1.1 +++ game.h 17 Mar 2004 04:48:23 -0000 1.2 @@ -59,7 +59,7 @@ * * @return true if all was ok, else false */ - virtual bool configure(Core *core) = 0; + virtual bool configure(Core* core) = 0; /** * Players for the next hand @@ -69,7 +69,7 @@ * * @return true if all was ok, else false */ - virtual bool next_hand(ID hand, std::list<ID> *players) = 0; + virtual bool next_hand(ID hand, std::list<ID>* players) = 0; /** * Check if the identificator is the first hand of this game Index: moduleio.h =================================================================== RCS file: /cvsroot/dmn/dmn/dmn/moduleio.h,v retrieving revision 1.3 retrieving revision 1.4 diff -u -d -r1.3 -r1.4 --- moduleio.h 29 Dec 2003 09:49:53 -0000 1.3 +++ moduleio.h 17 Mar 2004 04:48:23 -0000 1.4 @@ -63,31 +63,6 @@ */ class ModuleIO { - private: - /* Typedefs to access to the funtions */ - typedef Module* (*init_t)(); - typedef void (*end_t)(Module*); - - std::string path_; - lt_dlhandle handle_; - std::list<Module*> modules_; - init_t init_; - end_t end_; - - /** - * Open the module - * - * @param path path to the module - * - * @return true if the module can be opened or false if not - */ - bool open_module(const std::string& path); - - /** - * Close the module and all his instances - */ - void close_module(); - public: /** * Constructor @@ -179,6 +154,31 @@ * Destroy all the instances */ void destroy(); + + private: + /* Typedefs to access to the funtions */ + typedef Module* (*init_t)(); + typedef void (*end_t)(Module*); + + std::string path_; + lt_dlhandle handle_; + std::list<Module*> modules_; + init_t init_; + end_t end_; + + /** + * Open the module + * + * @param path path to the module + * + * @return true if the module can be opened or false if not + */ + bool open_module_(const std::string& path); + + /** + * Close the module and all his instances + */ + void close_module_(); }; }; Index: core.h =================================================================== RCS file: /cvsroot/dmn/dmn/dmn/core.h,v retrieving revision 1.1 retrieving revision 1.2 diff -u -d -r1.1 -r1.2 --- core.h 26 Dec 2003 20:09:11 -0000 1.1 +++ core.h 17 Mar 2004 04:48:23 -0000 1.2 @@ -103,7 +103,7 @@ * * @return true if there are some tournament */ - virtual bool tournaments(std::list<ID> *tournaments) = 0; + virtual bool tournaments(std::list<ID>* tournaments) = 0; /** * Matches in a tournament @@ -115,7 +115,7 @@ * * @return true if exist the tournament */ - virtual bool matches_in_tournament(ID tournament, std::list<ID> *matches) + virtual bool matches_in_tournament(ID tournament, std::list<ID>* matches) = 0; /** @@ -138,7 +138,7 @@ * * @return true if exist the tournament */ - virtual bool teams_in_tournament(ID tournament, std::list<ID> *teams) = 0; + virtual bool teams_in_tournament(ID tournament, std::list<ID>* teams) = 0; /** * Tournament of the team @@ -160,7 +160,7 @@ * * @return true if exist the tournament */ - virtual bool displays_in_tournament(ID tournament, std::list<ID> *displays) + virtual bool displays_in_tournament(ID tournament, std::list<ID>* displays) = 0; /** @@ -183,7 +183,7 @@ * * @return true if exist the match */ - virtual bool games_in_match(ID match, std::list<ID> *games) = 0; + virtual bool games_in_match(ID match, std::list<ID>* games) = 0; /** * Match owner of the game @@ -205,7 +205,7 @@ * * @return true if exist the match */ - virtual bool couples_in_match(ID match, std::list<ID> *couples) = 0; + virtual bool couples_in_match(ID match, std::list<ID>* couples) = 0; /** * Match of the couple @@ -227,7 +227,7 @@ * * @return true if exist the match */ - virtual bool displays_in_match(ID match, std::list<ID> *displays) = 0; + virtual bool displays_in_match(ID match, std::list<ID>* displays) = 0; /** * Match of the display @@ -249,7 +249,7 @@ * * @return true if exist the game */ - virtual bool hands_in_game(ID game, std::list<ID> *hands) = 0; + virtual bool hands_in_game(ID game, std::list<ID>* hands) = 0; /** * Game owner of the hand @@ -271,7 +271,7 @@ * * @return true if exist the game */ - virtual bool couples_in_game(ID game, std::list<ID> *couples) = 0; + virtual bool couples_in_game(ID game, std::list<ID>* couples) = 0; /** * Game of the couple @@ -293,7 +293,7 @@ * * @return true if exist the game */ - virtual bool displays_in_game(ID game, std::list<ID> *displays) = 0; + virtual bool displays_in_game(ID game, std::list<ID>* displays) = 0; /** * Game of the display @@ -315,7 +315,7 @@ * * @return true if exist the hand */ - virtual bool players_in_hand(ID hand, std::list<ID> *players) = 0; + virtual bool players_in_hand(ID hand, std::list<ID>* players) = 0; /** * Hand of the player @@ -337,7 +337,7 @@ * * @return true if exist the hand */ - virtual bool displays_in_hand(ID hand, std::list<ID> *displays) = 0; + virtual bool displays_in_hand(ID hand, std::list<ID>* displays) = 0; /** * Hand of the display @@ -381,7 +381,7 @@ * * @return true if exist the team */ - virtual bool couples_in_team(ID team, std::list<ID> *couples) = 0; + virtual bool couples_in_team(ID team, std::list<ID>* couples) = 0; /** * Team owner of the couple @@ -403,7 +403,7 @@ * * @return true if exist the couple */ - virtual bool players_in_couple(ID couple, std::list<ID> *players) = 0; + virtual bool players_in_couple(ID couple, std::list<ID>* players) = 0; /** * Couple owner of the player @@ -428,7 +428,7 @@ * @return true if all was ok, else false */ virtual bool classification_of_tournament(ID tournament, - std::list<ID> *teams) = 0; + std::list<ID>* teams) = 0; /*********** * Match * @@ -442,7 +442,7 @@ * @param match identifictor of the match * @param score where the score board is returned */ - virtual void score_board_match(ID match, std::list<Score> *score) = 0; + virtual void score_board_match(ID match, std::list<Score>* score) = 0; /*********** * Game * @@ -468,7 +468,7 @@ * * @return true if all was ok, else false */ - virtual void score_board_game(ID game, std::list<Score> *score) = 0; + virtual void score_board_game(ID game, std::list<Score>* score) = 0; /********** * Hand * Index: msg.h =================================================================== RCS file: /cvsroot/dmn/dmn/dmn/msg.h,v retrieving revision 1.5 retrieving revision 1.6 diff -u -d -r1.5 -r1.6 --- msg.h 26 Dec 2003 20:09:11 -0000 1.5 +++ msg.h 17 Mar 2004 04:48:23 -0000 1.6 @@ -53,7 +53,7 @@ * @param exit_status a error code to return * @param fmt message to show (printf style) */ - static void error(int exit_status, char *fmt, ...); + static void error(int exit_status, char* fmt, ...); /** * Shows a warning and continues @@ -70,7 +70,7 @@ * * @param fmt message to show (printf style) */ - static void warning(char *fmt, ...); + static void warning(char* fmt, ...); /** * Shows a message and continues @@ -87,7 +87,7 @@ * * @param fmt message to show (printf style) */ - static void info(char *fmt, ...); + static void info(char* fmt, ...); }; }; Index: sound.h =================================================================== RCS file: /cvsroot/dmn/dmn/dmn/sound.h,v retrieving revision 1.1 retrieving revision 1.2 diff -u -d -r1.1 -r1.2 --- sound.h 26 Dec 2003 20:09:11 -0000 1.1 +++ sound.h 17 Mar 2004 04:48:23 -0000 1.2 @@ -57,7 +57,7 @@ * * @return true if all was ok, else false */ - virtual bool configure(Core *core) = 0; + virtual bool configure(Core* core) = 0; /** * Mix the dominoes Index: match.h =================================================================== RCS file: /cvsroot/dmn/dmn/dmn/match.h,v retrieving revision 1.1 retrieving revision 1.2 diff -u -d -r1.1 -r1.2 --- match.h 26 Dec 2003 20:09:11 -0000 1.1 +++ match.h 17 Mar 2004 04:48:23 -0000 1.2 @@ -60,7 +60,7 @@ * * @return true if all was ok, else false */ - virtual bool configure(Core *core) = 0; + virtual bool configure(Core* core) = 0; /** * Couples for the next game @@ -70,7 +70,7 @@ * * @return true if all was ok, else false */ - virtual bool next_game(ID game, std::list<ID> *couples) = 0; + virtual bool next_game(ID game, std::list<ID>* couples) = 0; /** * Notify the winner of a game @@ -94,7 +94,7 @@ * * @param score where the score board is returned */ - virtual void score_board(std::list<Score> *score) = 0; + virtual void score_board(std::list<Score>* score) = 0; /** * Winner of the match Index: hand.h =================================================================== RCS file: /cvsroot/dmn/dmn/dmn/hand.h,v retrieving revision 1.1 retrieving revision 1.2 diff -u -d -r1.1 -r1.2 --- hand.h 26 Dec 2003 20:09:11 -0000 1.1 +++ hand.h 17 Mar 2004 04:48:23 -0000 1.2 @@ -60,7 +60,7 @@ * * @return true if all was ok, else false */ - virtual bool configure(Core *core) = 0; + virtual bool configure(Core* core) = 0; /** * Player who started the hand @@ -104,7 +104,7 @@ * * @return the number of dominoes */ - virtual int dominoes_played(Dominoes *dominoes) = 0; + virtual int dominoes_played(Dominoes* dominoes) = 0; /** * Return the number of dominoes that a player has @@ -125,7 +125,7 @@ * @return true if the tile is shuffled, or false if all the tiles are * shuffled or error */ - virtual bool shuffle_tile(ID *player, Domino *domino) = 0; + virtual bool shuffle_tile(ID* player, Domino* domino) = 0; /** * Check if a movement is valid or not @@ -157,7 +157,7 @@ * * @return true if a domino is gived to the player or false if not */ - virtual bool set_player_pass(ID player, Domino *domino) = 0; + virtual bool set_player_pass(ID player, Domino* domino) = 0; /** * Check if the game is finished (there is a winner) @@ -168,7 +168,7 @@ * * @return player winner or ID_NULL if there isn't one */ - virtual ID winner(Points *points) = 0; + virtual ID winner(Points* points) = 0; /** * Check if the hand is finished or not Index: id.h =================================================================== RCS file: /cvsroot/dmn/dmn/dmn/id.h,v retrieving revision 1.1 retrieving revision 1.2 diff -u -d -r1.1 -r1.2 --- id.h 26 Dec 2003 20:09:11 -0000 1.1 +++ id.h 17 Mar 2004 04:48:23 -0000 1.2 @@ -44,9 +44,6 @@ */ class IDs { - private: - std::set<ID> ids_; - public: /** * Create a new identificator @@ -79,6 +76,9 @@ * @return the number of elements */ unsigned short size(); + + private: + std::set<ID> ids_; }; }; Index: dominoes.h =================================================================== RCS file: /cvsroot/dmn/dmn/dmn/dominoes.h,v retrieving revision 1.1 retrieving revision 1.2 diff -u -d -r1.1 -r1.2 --- dominoes.h 26 Dec 2003 20:09:11 -0000 1.1 +++ dominoes.h 17 Mar 2004 04:48:23 -0000 1.2 @@ -36,9 +36,6 @@ */ class Dominoes { - private: - std::list<Domino> dominoes_; - public: /** * Number of dominoes in the list @@ -120,6 +117,9 @@ */ friend bool operator!=(const Dominoes& dominoes1, const Dominoes& dominoes2); + + private: + std::list<Domino> dominoes_; }; }; Index: moduleio.cpp =================================================================== RCS file: /cvsroot/dmn/dmn/dmn/moduleio.cpp,v retrieving revision 1.3 retrieving revision 1.4 diff -u -d -r1.3 -r1.4 --- moduleio.cpp 29 Dec 2003 09:49:53 -0000 1.3 +++ moduleio.cpp 17 Mar 2004 04:48:23 -0000 1.4 @@ -46,7 +46,7 @@ ModuleIO::ModuleIO(const string& path) { - if (!open_module(path)) { + if (!open_module_(path)) { path_ = string(""); handle_ = NULL; init_ = NULL; @@ -93,7 +93,7 @@ path += name; path += PLUGIN_EXT; - if (type == ModuleNONE || !open_module(path)) { + if (type == ModuleNONE || !open_module_(path)) { path_ = string(""); handle_ = NULL; init_ = NULL; @@ -103,61 +103,12 @@ ModuleIO::~ModuleIO() { - close_module(); -} - -bool ModuleIO::open_module(const string& path) -{ - lt_dlinit(); - - handle_ = lt_dlopenext(path.c_str()); - if (handle_ == NULL) { - Msg::warning("Can't open module %s (%s)\n", path.c_str(), lt_dlerror()); - goto end1; - } - - init_ = (init_t) lt_dlsym(handle_, "Module_init"); - if (init_ == NULL) { - Msg::warning("Can't load Module_init() from module %s (%s)\n", - path.c_str(), lt_dlerror()); - goto end2; - } - - end_ = (end_t) lt_dlsym(handle_, "Module_end"); - if (end_ == NULL) { - Msg::warning("Can't load Module_end() from module %s (%s)\n", - path.c_str(), lt_dlerror()); - goto end3; - } - - path_ = path; - - return true; - - end3: - init_ = NULL; - end2: - lt_dlclose(handle_); - handle_ = NULL; - end1: - return false; -} - -void ModuleIO::close_module() -{ - while (modules_.begin() != modules_.end()) { - end_(*modules_.begin()); - modules_.erase(modules_.begin()); - } - - lt_dlclose(handle_); - lt_dlexit(); - handle_ = NULL; + close_module_(); } bool ModuleIO::open(const std::string& path) { - return open_module(path); + return open_module_(path); } bool ModuleIO::open(ModuleType type, const std::string& name) @@ -202,7 +153,7 @@ path += name; path += PLUGIN_EXT; - return open_module(path); + return open_module_(path); } void ModuleIO::close() @@ -210,7 +161,7 @@ if (!is_open()) return; - close_module(); + close_module_(); } const string ModuleIO::path() const @@ -256,3 +207,52 @@ modules_.erase(modules_.begin()); } } + +bool ModuleIO::open_module_(const string& path) +{ + lt_dlinit(); + + handle_ = lt_dlopenext(path.c_str()); + if (handle_ == NULL) { + Msg::warning("Can't open module %s (%s)\n", path.c_str(), lt_dlerror()); + goto end1; + } + + init_ = (init_t) lt_dlsym(handle_, "Module_init"); + if (init_ == NULL) { + Msg::warning("Can't load Module_init() from module %s (%s)\n", + path.c_str(), lt_dlerror()); + goto end2; + } + + end_ = (end_t) lt_dlsym(handle_, "Module_end"); + if (end_ == NULL) { + Msg::warning("Can't load Module_end() from module %s (%s)\n", + path.c_str(), lt_dlerror()); + goto end3; + } + + path_ = path; + + return true; + + end3: + init_ = NULL; + end2: + lt_dlclose(handle_); + handle_ = NULL; + end1: + return false; +} + +void ModuleIO::close_module_() +{ + while (modules_.begin() != modules_.end()) { + end_(*modules_.begin()); + modules_.erase(modules_.begin()); + } + + lt_dlclose(handle_); + lt_dlexit(); + handle_ = NULL; +} Index: domino.h =================================================================== RCS file: /cvsroot/dmn/dmn/dmn/domino.h,v retrieving revision 1.1 retrieving revision 1.2 diff -u -d -r1.1 -r1.2 --- domino.h 26 Dec 2003 20:09:11 -0000 1.1 +++ domino.h 17 Mar 2004 04:48:23 -0000 1.2 @@ -38,9 +38,6 @@ */ class HalfDomino { - private: - int half_; - public: /** * Constructor @@ -94,6 +91,9 @@ */ friend bool operator!=(const HalfDomino& halfdomino1, const HalfDomino& halfdomino2); + + private: + int half_; }; /** @@ -101,10 +101,6 @@ */ class Domino { - private: - HalfDomino half1_; - HalfDomino half2_; - public: /** * Constructor @@ -174,6 +170,10 @@ * @return true if the dominoes are different, false if not */ friend bool operator!=(const Domino& domino1, const Domino& domino2); + + private: + HalfDomino half1_; + HalfDomino half2_; }; // Invalid values |
|
From: Xos? O. <xos...@us...> - 2004-03-17 04:58:18
|
Update of /cvsroot/dmn/dmn/src/Config In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv7239/src/Config Modified Files: configfile.cpp configfile.h default.cpp default.h Log Message: Now all the code follow the coding style (doc/CodingStyle) Index: default.h =================================================================== RCS file: /cvsroot/dmn/dmn/src/Config/default.h,v retrieving revision 1.2 retrieving revision 1.3 diff -u -d -r1.2 -r1.3 --- default.h 28 Dec 2003 05:38:31 -0000 1.2 +++ default.h 17 Mar 2004 04:48:23 -0000 1.3 @@ -46,6 +46,24 @@ */ class ConfigDefault: public Config { + public: + /** + * Constructor + */ + ConfigDefault(); + + bool configure(int argc, char* argv[]); + std::string config(); + std::string core(const std::string& default_option); + std::string display(const std::string& default_option); + std::string sound(const std::string& default_option); + std::string tournament(const std::string& default_option); + std::string match(const std::string& default_option); + std::string game(const std::string& default_option); + std::string hand(const std::string& default_option); + std::list<dmn::PlayerInfo> teams(const std::list<PlayerInfo> + default_option); + private: std::string configpath_; ConfigFile configfile_; @@ -68,7 +86,7 @@ * @return the position of the point or the length of the string if the * string hasn't one */ - int last_point(const char *str); + int last_point_(const char* str); /** * Return the string representation of a Module_t @@ -77,7 +95,7 @@ * * @return the string or NULL if type is not correct */ - const char *module_str(ModuleType type); + const char* module_str_(ModuleType type); /** * List all the modules availables in the directory and subdirectories @@ -86,24 +104,24 @@ * * @return 1 if dirname is a directory and could be opened or 0 if not */ - int list_dir(char *dirname); + int list_dir_(char* dirname); /** * List all the modules availables * * @return 1 if all was ok, else 0 */ - int list(); + int list_(); /** * Show the usage information */ - void usage(int status); + void usage_(int status); /** * Show the version information */ - void version(); + void version_(); /** * Parse the command line @@ -111,42 +129,24 @@ * @param argc number of arguments * @param argv arguments */ - void parse_command_line(int argc, char *argv[]); + void parse_command_line_(int argc, char* argv[]); /** * Create a default configuration file * * @return true if the file was created, false if not */ - bool create_configuration_file(); + bool create_configuration_file_(); /** * Parse the configuration file */ - void parse_file(); + void parse_file_(); /** * Check the command line options */ - void check_options(); - - public: - /** - * Constructor - */ - ConfigDefault(); - - bool configure(int argc, char *argv[]); - std::string config(); - std::string core(const std::string& default_option); - std::string display(const std::string& default_option); - std::string sound(const std::string& default_option); - std::string tournament(const std::string& default_option); - std::string match(const std::string& default_option); - std::string game(const std::string& default_option); - std::string hand(const std::string& default_option); - std::list<dmn::PlayerInfo> teams(const std::list<PlayerInfo> - default_option); + void check_options_(); }; }; Index: default.cpp =================================================================== RCS file: /cvsroot/dmn/dmn/src/Config/default.cpp,v retrieving revision 1.3 retrieving revision 1.4 diff -u -d -r1.3 -r1.4 --- default.cpp 29 Dec 2003 04:31:51 -0000 1.3 +++ default.cpp 17 Mar 2004 04:48:23 -0000 1.4 @@ -59,13 +59,69 @@ ConfigDefault::ConfigDefault() { set_name(_("Default Config")); - set_version("1.0"); + set_version_("1.0"); set_desc(_("dmn Main Config Module")); configpath_ = string(getenv("HOME")) + '/' + DMNRC; } -int ConfigDefault::last_point(const char *str) +bool ConfigDefault::configure(int argc, char* argv[]) +{ + parse_command_line_(argc, argv); + parse_file_(); + parse_command_line_(argc, argv); + check_options_(); + + return true; +} + +string ConfigDefault::config() +{ + return Config_; +} + +string ConfigDefault::core(const string& default_option) +{ + return Core_; +} + +string ConfigDefault::display(const string& default_option) +{ + return Display_; +} + +string ConfigDefault::sound(const string& default_option) +{ + return Sound_; +} + +string ConfigDefault::tournament(const string& default_option) +{ + return Tournament_; +} + +string ConfigDefault::match(const string& default_option) +{ + return Match_; +} + +string ConfigDefault::game(const string& default_option) +{ + return Game_; +} + +string ConfigDefault::hand(const string& default_option) +{ + return Hand_; +} + +std::list<dmn::PlayerInfo> ConfigDefault::teams(const std::list<PlayerInfo> + default_option) +{ + return Teams_; +} + +int ConfigDefault::last_point_(const char* str) { int i; for (i = strlen(str) - 1; i > 0; i--) { @@ -76,9 +132,9 @@ return strlen(str); } -const char *ConfigDefault::module_str(ModuleType type) +const char* ConfigDefault::module_str_(ModuleType type) { - static char *str[] = { + static char* str[] = { "none", "Config", "Display", @@ -96,39 +152,39 @@ return NULL; } -int ConfigDefault::list_dir(char *dirname) +int ConfigDefault::list_dir_(char* dirname) { - DIR *directory = opendir(dirname); + DIR* directory = opendir(dirname); if (directory == NULL) return 0; - struct dirent *content; + struct dirent* content; while ((content = readdir(directory)) != NULL) { if (strcmp(content->d_name, ".") && strcmp(content->d_name, "..")) { - char *sondirname = new char[strlen(dirname) + strlen(content->d_name) + char* sondirname = new char[strlen(dirname) + strlen(content->d_name) + 2]; strcpy(sondirname, dirname); strcat(sondirname, "/"); strcat(sondirname, content->d_name); - int point = last_point(content->d_name); + int point = last_point_(content->d_name); if (!strcmp(content->d_name + point, PLUGIN_EXT)) { ModuleIO moduleio(sondirname); - Module *module = moduleio.create(); + Module* module = moduleio.create(); if (module != NULL) { - char *module_name = (char *) new char[point + 1]; + char* module_name = (char*) new char[point + 1]; strncpy(module_name, content->d_name, point); module_name[point] = '\0'; printf("%s:\t%s\t%s\t%s\t%s\n", module_name, - module_str(module->type()), module->name().c_str(), - module->version().c_str(), module->desc().c_str()); + module_str_(module->type()), module->name().c_str(), + module->version_().c_str(), module->desc().c_str()); delete[] module_name; moduleio.close(); } } else - list_dir(sondirname); + list_dir_(sondirname); delete[] sondirname; } @@ -139,13 +195,13 @@ return 1; } -int ConfigDefault::list() +int ConfigDefault::list_() { puts(_("Module\tType\tName\tVersion\tDescription")); - return list_dir(PLUGIN_DIR); + return list_dir_(PLUGIN_DIR); } -void ConfigDefault::usage(int status) +void ConfigDefault::usage_(int status) { if (status != 0) printf(_("Try '%s --help' for more information.\n"), @@ -179,7 +235,7 @@ } } -void ConfigDefault::version() +void ConfigDefault::version_() { printf("\ %s %s\n\ @@ -193,7 +249,7 @@ ")); } -void ConfigDefault::parse_command_line(int argc, char *argv[]) +void ConfigDefault::parse_command_line_(int argc, char* argv[]) { struct option long_options[] = { {"list", no_argument, NULL, 'l'}, @@ -223,7 +279,7 @@ switch (c) { case 'l': - list(); + list_(); exit(0); case 'C': Config_ = optarg; @@ -253,14 +309,14 @@ configpath_ = optarg; break; case 'h': - usage(0); + usage_(0); exit(0); case 'v': - version(); + version_(); exit(0); default: - usage(1); + usage_(1); exit(1); } } @@ -268,12 +324,12 @@ if (optind < argc) { while (optind < argc) Msg::warning(_("Unknown argument (%s)\n"), argv[optind++]); - usage(1); + usage_(1); exit(1); } } -bool ConfigDefault::create_configuration_file() +bool ConfigDefault::create_configuration_file_() { ofstream dmnrc(configpath_.c_str()); if (!dmnrc) @@ -318,14 +374,14 @@ return true; } -void ConfigDefault::parse_file() +void ConfigDefault::parse_file_() { // If the configuration file doesn't exist, create it ifstream dmnrc(configpath_.c_str()); if (dmnrc) dmnrc.close(); else { - if (create_configuration_file()) + if (create_configuration_file_()) Msg::info(_("%s created. See it and modify it\n"), configpath_.c_str()); else Msg::warning(_("Can't be created the configuration file %s\n"), @@ -333,7 +389,7 @@ } try { - configfile_.parse_file(configpath_); + configfile_.parse_file_(configpath_); } catch (const xmlpp::exception& ex) { Msg::error(1, _("Can't parse configuration file")); @@ -350,7 +406,7 @@ Teams_ = configfile_.players(); } -void ConfigDefault::check_options() +void ConfigDefault::check_options_() { if (Config_ == string("")) Msg::error(1, _("Config module not set!\n")); @@ -371,59 +427,3 @@ if (Teams_.size() < 2) Msg::error(1, _("Insufficient (%d) number of teams!\n"), Teams_.size()); } - -bool ConfigDefault::configure(int argc, char *argv[]) -{ - parse_command_line(argc, argv); - parse_file(); - parse_command_line(argc, argv); - check_options(); - - return true; -} - -string ConfigDefault::config() -{ - return Config_; -} - -string ConfigDefault::core(const string& default_option) -{ - return Core_; -} - -string ConfigDefault::display(const string& default_option) -{ - return Display_; -} - -string ConfigDefault::sound(const string& default_option) -{ - return Sound_; -} - -string ConfigDefault::tournament(const string& default_option) -{ - return Tournament_; -} - -string ConfigDefault::match(const string& default_option) -{ - return Match_; -} - -string ConfigDefault::game(const string& default_option) -{ - return Game_; -} - -string ConfigDefault::hand(const string& default_option) -{ - return Hand_; -} - -std::list<dmn::PlayerInfo> ConfigDefault::teams(const std::list<PlayerInfo> - default_option) -{ - return Teams_; -} Index: configfile.h =================================================================== RCS file: /cvsroot/dmn/dmn/src/Config/configfile.h,v retrieving revision 1.1 retrieving revision 1.2 diff -u -d -r1.1 -r1.2 --- configfile.h 26 Dec 2003 20:09:12 -0000 1.1 +++ configfile.h 17 Mar 2004 04:48:23 -0000 1.2 @@ -42,17 +42,6 @@ */ class ConfigFile: public xmlpp::SaxParser { - private: - std::string config_, core_, display_, sound_, - tournament_, match_, game_, hand_; - std::list<PlayerInfo> players_; - - unsigned long team_, couple_; - - protected: - void on_start_element(const std::string & name, - const AttributeMap & attributes); - public: /** * Constructor @@ -121,6 +110,17 @@ * @return a list of PlayerInfo with all the players */ std::list<PlayerInfo> players(); + + protected: + void on_start_element(const std::string& name, + const AttributeList& attributes); + + private: + std::string config_, core_, display_, sound_, + tournament_, match_, game_, hand_; + std::list<PlayerInfo> players_; + + unsigned long team_, couple_; }; }; Index: configfile.cpp =================================================================== RCS file: /cvsroot/dmn/dmn/src/Config/configfile.cpp,v retrieving revision 1.1 retrieving revision 1.2 diff -u -d -r1.1 -r1.2 --- configfile.cpp 26 Dec 2003 20:09:12 -0000 1.1 +++ configfile.cpp 17 Mar 2004 04:48:23 -0000 1.2 @@ -35,8 +35,53 @@ couple_ = 0; } -void ConfigFile::on_start_element(const string & name, - const AttributeMap & attributes) +std::string ConfigFile::config() +{ + return config_; +} + +std::string ConfigFile::core() +{ + return core_; +} + +std::string ConfigFile::display() +{ + return display_; +} + +std::string ConfigFile::sound() +{ + return sound_; +} + +std::string ConfigFile::tournament() +{ + return tournament_; +} + +std::string ConfigFile::match() +{ + return match_; +} + +std::string ConfigFile::game() +{ + return game_; +} + +std::string ConfigFile::hand() +{ + return hand_; +} + +list<PlayerInfo> ConfigFile::players() +{ + return players_; +} + +void ConfigFile::on_start_element(const string& name, + const AttributeList& attributes) { if (name == "dmn:team") // A new team team_++; @@ -50,7 +95,7 @@ player.team = team_; player.couple = couple_; - AttributeMap::const_iterator iter = attributes.find("name"); + AttributeList::const_iterator iter = attributes.find("name"); if (iter == attributes.end()) return; player.name = (*iter).second; @@ -64,7 +109,7 @@ if (attributes.size() != 1) return; - AttributeMap::const_iterator iter = attributes.find("module"); + AttributeList::const_iterator iter = attributes.find("module"); if (iter == attributes.end()) return; @@ -86,48 +131,3 @@ hand_ = (*iter).second; } } - -std::string ConfigFile::config() -{ - return config_; -} - -std::string ConfigFile::core() -{ - return core_; -} - -std::string ConfigFile::display() -{ - return display_; -} - -std::string ConfigFile::sound() -{ - return sound_; -} - -std::string ConfigFile::tournament() -{ - return tournament_; -} - -std::string ConfigFile::match() -{ - return match_; -} - -std::string ConfigFile::game() -{ - return game_; -} - -std::string ConfigFile::hand() -{ - return hand_; -} - -list<PlayerInfo> ConfigFile::players() -{ - return players_; -} |
|
From: Xos? O. <xos...@us...> - 2004-03-17 04:58:17
|
Update of /cvsroot/dmn/dmn/src In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv7239/src Modified Files: main.cpp Log Message: Now all the code follow the coding style (doc/CodingStyle) Index: main.cpp =================================================================== RCS file: /cvsroot/dmn/dmn/src/main.cpp,v retrieving revision 1.5 retrieving revision 1.6 diff -u -d -r1.5 -r1.6 --- main.cpp 7 Jan 2004 10:43:00 -0000 1.5 +++ main.cpp 17 Mar 2004 04:48:23 -0000 1.6 @@ -53,8 +53,8 @@ */ ModuleIO coreio; -Config *config; -Core *core; +Config* config; +Core* core; /** * Open Config and Core modules @@ -64,7 +64,7 @@ * * @return true if all was ok, or false if not */ -bool configuration(int argc, char *argv[]); +bool configuration(int argc, char* argv[]); /** * Play the game @@ -116,7 +116,7 @@ * * @return 0 if all was ok, or other number if not */ -int main(int argc, char *argv[]) +int main(int argc, char* argv[]) { #ifdef ENABLE_NLS /* gettext */ @@ -147,7 +147,7 @@ exit(0); } -bool configuration(int argc, char *argv[]) +bool configuration(int argc, char* argv[]) { if (!configio.open(ModuleConfig, DEFAULT_CONFIG)) return false; |
|
From: Xos? O. <xos...@us...> - 2004-03-17 04:58:17
|
Update of /cvsroot/dmn/dmn/doc In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv7239/doc Modified Files: CodingStyle Log Message: Now all the code follow the coding style (doc/CodingStyle) Index: CodingStyle =================================================================== RCS file: /cvsroot/dmn/dmn/doc/CodingStyle,v retrieving revision 1.7 retrieving revision 1.8 diff -u -d -r1.7 -r1.8 --- CodingStyle 16 Mar 2004 03:52:31 -0000 1.7 +++ CodingStyle 17 Mar 2004 04:48:23 -0000 1.8 @@ -59,7 +59,6 @@ iii) Avoid the temptation of aligning the variable names in your declarations at a given column. iv) In classes, first public members, then protected and finally private. -* Currently, this point is not followed, but new code MUST. The old code will be changed. v) All private class members should finish with _. This makes it easier to recognize them in any context. Example: |
|
From: Xos? O. <xos...@us...> - 2004-03-17 04:58:05
|
Update of /cvsroot/dmn/dmn/src/Sound In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv7239/src/Sound Modified Files: alsa.cpp alsa.h null.cpp null.h null_module.cpp soundogg.cpp soundogg.h Log Message: Now all the code follow the coding style (doc/CodingStyle) Index: null_module.cpp =================================================================== RCS file: /cvsroot/dmn/dmn/src/Sound/null_module.cpp,v retrieving revision 1.2 retrieving revision 1.3 diff -u -d -r1.2 -r1.3 --- null_module.cpp 26 Dec 2003 21:52:20 -0000 1.2 +++ null_module.cpp 17 Mar 2004 04:48:40 -0000 1.3 @@ -30,12 +30,12 @@ using namespace dmn; -Module *Module_init() +Module* Module_init() { return new SoundNull; } -void Module_end(Module *module) +void Module_end(Module* module) { delete (SoundNull*) module; } Index: null.cpp =================================================================== RCS file: /cvsroot/dmn/dmn/src/Sound/null.cpp,v retrieving revision 1.1 retrieving revision 1.2 diff -u -d -r1.1 -r1.2 --- null.cpp 26 Dec 2003 20:09:14 -0000 1.1 +++ null.cpp 17 Mar 2004 04:48:40 -0000 1.2 @@ -35,7 +35,7 @@ set_desc(_("It doesn't play sounds, but works :)")); } -bool SoundNull::configure(Core *core) +bool SoundNull::configure(Core* core) { return true; } Index: alsa.h =================================================================== RCS file: /cvsroot/dmn/dmn/src/Sound/alsa.h,v retrieving revision 1.1 retrieving revision 1.2 diff -u -d -r1.1 -r1.2 --- alsa.h 26 Dec 2003 20:09:14 -0000 1.1 +++ alsa.h 17 Mar 2004 04:48:40 -0000 1.2 @@ -43,15 +43,31 @@ */ class SoundAlsa: public Sound { + public: + /** + * Constructor + */ + SoundAlsa(); + + /** + * Destructor + */ + SoundAlsa::~SoundAlsa(); + + bool configure(Core *core); + void mix_dominoes(); + void domino_played(ID player, Domino domino, HalfDomino half); + void player_pass(ID player); + private: /** Save PCM sound and its length */ struct data_pcm_t { - char *buffer; + char* buffer; unsigned long length; }; - Core *core_; /* Core */ - snd_pcm_t *playback_handle_; /**< ALSA playback handle */ + Core* core_; /* Core */ + snd_pcm_t* playback_handle_; /**< ALSA playback handle */ data_pcm_t *mix_, *play_domino_, *pass_; /**< PCM sounds */ /** @@ -61,9 +77,10 @@ * @param channels number of sound channels * @param rate sound rate * - * @return a pointer with the data_pcm_t structure or NULL if a error happend + * @return a pointer with the data_pcm_t structure or NULL if a error + * happend */ - data_pcm_t *new_pcm(char *filename, short *channels, unsigned long *rate); + data_pcm_t* new_pcm_(char* filename, short* channels, unsigned long* rate); /** * Initiate ALSA @@ -73,12 +90,12 @@ * * @return 1 if all was ok, or 0 if not */ - int init_alsa(short channels, unsigned long rate); + int init_alsa_(short channels, unsigned long rate); /** * End ALSA */ - void end_alsa(); + void end_alsa_(); /** * Play a PCM sound in ALSA device @@ -88,23 +105,7 @@ * * @return 1 if all was ok, or 0 if not */ - int play_alsa(char buffer[], int length); - - public: - /** - * Constructor - */ - SoundAlsa(); - - /** - * Destructor - */ - SoundAlsa::~SoundAlsa(); - - bool configure(Core *core); - void mix_dominoes(); - void domino_played(ID player, Domino domino, HalfDomino half); - void player_pass(ID player); + int play_alsa_(char buffer[], int length); }; }; Index: alsa.cpp =================================================================== RCS file: /cvsroot/dmn/dmn/src/Sound/alsa.cpp,v retrieving revision 1.1 retrieving revision 1.2 diff -u -d -r1.1 -r1.2 --- alsa.cpp 26 Dec 2003 20:09:14 -0000 1.1 +++ alsa.cpp 17 Mar 2004 04:48:40 -0000 1.2 @@ -69,14 +69,14 @@ || rate[0] != rate[1] || rate[0] != rate[2]) { Msg::warning("Files have different number of channels or rates"); - end_alsa(); + end_alsa_(); delete mix_; delete play_domino_; delete pass_; playback_handle_ = NULL; - } else if (!init_alsa(channels[0], rate[0])) { + } else if (!init_alsa_(channels[0], rate[0])) { Msg::warning("Can't be init alsa"); - end_alsa(); + end_alsa_(); delete mix_; delete play_domino_; delete pass_; @@ -87,7 +87,7 @@ SoundAlsa::~SoundAlsa() { if (playback_handle_ != NULL) { - end_alsa(); + end_alsa_(); delete mix_; delete play_domino_; delete pass_; @@ -95,7 +95,35 @@ } } -int SoundAlsa::init_alsa(short channels, unsigned long rate) +bool SoundAlsa::configure(Core *core) +{ + if (core_ == NULL) + return false; + + core_ = core; + + return true; +} + +void SoundAlsa::mix_dominoes() +{ + if (playback_handle_ != NULL && mix_ != NULL) + play_alsa_(mix_->buffer, mix_->length); +} + +void SoundAlsa::domino_played(ID player, Domino domino, HalfDomino half) +{ + if (playback_handle_ != NULL && play_domino_ != NULL) + play_alsa_(play_domino_->buffer, play_domino_->length); +} + +void SoundAlsa::player_pass(ID player) +{ + if (playback_handle_ != NULL && pass_ != NULL) + play_alsa_(pass_->buffer, pass_->length); +} + +int SoundAlsa::init_alsa_(short channels, unsigned long rate) { int err; snd_pcm_hw_params_t *hw_params; @@ -164,12 +192,12 @@ return 1; } -void SoundAlsa::end_alsa() +void SoundAlsa::end_alsa_() { snd_pcm_close(playback_handle_); } -int SoundAlsa::play_alsa(char buffer[], int length) +int SoundAlsa::play_alsa_(char buffer[], int length) { if (playback_handle_ == NULL) return 0; @@ -202,31 +230,3 @@ return 1; } - -bool SoundAlsa::configure(Core *core) -{ - if (core_ == NULL) - return false; - - core_ = core; - - return true; -} - -void SoundAlsa::mix_dominoes() -{ - if (playback_handle_ != NULL && mix_ != NULL) - play_alsa(mix_->buffer, mix_->length); -} - -void SoundAlsa::domino_played(ID player, Domino domino, HalfDomino half) -{ - if (playback_handle_ != NULL && play_domino_ != NULL) - play_alsa(play_domino_->buffer, play_domino_->length); -} - -void SoundAlsa::player_pass(ID player) -{ - if (playback_handle_ != NULL && pass_ != NULL) - play_alsa(pass_->buffer, pass_->length); -} Index: null.h =================================================================== RCS file: /cvsroot/dmn/dmn/src/Sound/null.h,v retrieving revision 1.1 retrieving revision 1.2 diff -u -d -r1.1 -r1.2 --- null.h 26 Dec 2003 20:09:14 -0000 1.1 +++ null.h 17 Mar 2004 04:48:40 -0000 1.2 @@ -44,7 +44,7 @@ */ SoundNull(); - bool configure(Core *core); + bool configure(Core* core); void mix_dominoes(); void domino_played(ID player, Domino domino, HalfDomino half); void player_pass(ID player); Index: soundogg.h =================================================================== RCS file: /cvsroot/dmn/dmn/src/Sound/soundogg.h,v retrieving revision 1.1 retrieving revision 1.2 diff -u -d -r1.1 -r1.2 --- soundogg.h 26 Dec 2003 20:09:14 -0000 1.1 +++ soundogg.h 17 Mar 2004 04:48:40 -0000 1.2 @@ -48,9 +48,9 @@ * * @return true if all was ok, or false if not */ - static bool to_pcm(char *filename, char **pcm, - unsigned long *length, short *channels, - unsigned long *rate); + static bool to_pcm(char* filename, char** pcm, + unsigned long* length, short* channels, + unsigned long* rate); }; }; Index: soundogg.cpp =================================================================== RCS file: /cvsroot/dmn/dmn/src/Sound/soundogg.cpp,v retrieving revision 1.1 retrieving revision 1.2 diff -u -d -r1.1 -r1.2 --- soundogg.cpp 26 Dec 2003 20:09:14 -0000 1.1 +++ soundogg.cpp 17 Mar 2004 04:48:40 -0000 1.2 @@ -38,12 +38,12 @@ #define VORBIS_WORD 2 #define VORBIS_SIGNED 1 -bool SoundOgg::to_pcm(char *filename, char **pcm, - unsigned long *length, short *channels, - unsigned long *rate) +bool SoundOgg::to_pcm(char* filename, char** pcm, + unsigned long* length, short* channels, + unsigned long* rate) { /* Open the file */ - FILE *file = fopen(filename, "r"); + FILE* file = fopen(filename, "r"); if (file == NULL) { Msg::warning(_("%s can't be opened\n"), filename); return false; @@ -56,7 +56,7 @@ } /* OggVorbis information */ - vorbis_info *vi = ov_info(&vf, -1); + vorbis_info* vi = ov_info(&vf, -1); *channels = vi->channels; *rate = vi->rate; |
|
From: Xos? O. <xos...@us...> - 2004-03-17 04:58:05
|
Update of /cvsroot/dmn/dmn/src/Game In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv7239/src/Game Modified Files: to20_module.cpp to30_module.cpp to40_module.cpp toX.cpp toX.h Log Message: Now all the code follow the coding style (doc/CodingStyle) Index: to40_module.cpp =================================================================== RCS file: /cvsroot/dmn/dmn/src/Game/to40_module.cpp,v retrieving revision 1.1 retrieving revision 1.2 diff -u -d -r1.1 -r1.2 --- to40_module.cpp 26 Dec 2003 20:09:13 -0000 1.1 +++ to40_module.cpp 17 Mar 2004 04:48:39 -0000 1.2 @@ -28,12 +28,12 @@ using namespace dmn; -Module *Module_init() +Module* Module_init() { return new GameTo40; } -void Module_end(Module *module) +void Module_end(Module* module) { delete (GameTo40*) module; } Index: toX.h =================================================================== RCS file: /cvsroot/dmn/dmn/src/Game/toX.h,v retrieving revision 1.1 retrieving revision 1.2 diff -u -d -r1.1 -r1.2 --- toX.h 26 Dec 2003 20:09:13 -0000 1.1 +++ toX.h 17 Mar 2004 04:48:39 -0000 1.2 @@ -25,7 +25,6 @@ #ifndef GAME_TOX_H #define GAME_TOX_H 1 - #include <dmn/game.h> #include <list> @@ -37,8 +36,26 @@ */ class GameToX: public Game { + public: + /** + * Constructor + * + * @param max_points points needed to win the game + */ + GameToX(Points max_points); + + bool configure(Core* core); + bool next_hand(ID hand, std::list<ID>* players); + bool is_first_hand(ID hand); + void set_hand_winner(ID hand, ID couple, Points points); + Points points_to_win(); + void score_board(std::list<Score>* score); + ID next_turn(); + ID winner(); + bool is_finished(); + private: - Core *core_; // Core + Core* core_; // Core ID hand_; // hand played now std::list<Score> couples_; // List of score_t ID player_starts_hand_; @@ -53,7 +70,7 @@ * * @return the identificator of the player or DMN_ID_NULL if is not found */ - ID player_in_position(ID couple, unsigned long position); + ID player_in_position_(ID couple, unsigned long position); /** * Order the players for the hand @@ -63,43 +80,25 @@ * * @return true if all was ok, else false */ - bool players_in_order(std::list<ID> couples, std::list<ID> *players); + bool players_in_order_(std::list<ID> couples, std::list<ID>* players); /** * Check if the game is finished * - * @return the identificator of the winner or DMN_ID_NULL if the game is not - * finished + * @return the identificator of the winner or DMN_ID_NULL if the game is + * not finished */ - ID is_game_finished(); + ID is_game_finished_(); /** * Calculate the player who follows other * * @param player actual player (we want to know the next one) * - * @return the identificator of the next player or DMN_ID_NULL if the player - * is not found or error - */ - ID next_player(ID player); - - public: - /** - * Constructor - * - * @param max_points points needed to win the game + * @return the identificator of the next player or DMN_ID_NULL if the + * player is not found or error */ - GameToX(Points max_points); - - bool configure(Core *core); - bool next_hand(ID hand, std::list<ID> *players); - bool is_first_hand(ID hand); - void set_hand_winner(ID hand, ID couple, Points points); - Points points_to_win(); - void score_board(std::list<Score> *score); - ID next_turn(); - ID winner(); - bool is_finished(); + ID next_player_(ID player); }; }; Index: toX.cpp =================================================================== RCS file: /cvsroot/dmn/dmn/src/Game/toX.cpp,v retrieving revision 1.1 retrieving revision 1.2 diff -u -d -r1.1 -r1.2 --- toX.cpp 26 Dec 2003 20:09:13 -0000 1.1 +++ toX.cpp 17 Mar 2004 04:48:39 -0000 1.2 @@ -32,93 +32,7 @@ max_points_ = max_points; } -ID GameToX::player_in_position(ID couple, unsigned long position) -{ - list<ID> players; - if (!core_->players_in_couple(couple, &players)) - return ID_NULL; - - if (position >= players.size()) - return ID_NULL; - - list<ID>::const_iterator player = players.begin(); - while (position > 0) { - ++player; - position--; - } - - return *player; -} - -bool GameToX::players_in_order(list<ID> couples, list<ID> *players) -{ - bool continue_bucle = true; - unsigned long position = 0; - while (continue_bucle) { - continue_bucle = false; - - list<ID>::const_iterator couple = couples.begin(); - while (couple != couples.end()) { - ID id = player_in_position(*couple, position); - if (id != ID_NULL) { - continue_bucle = true; - players->push_back(id); - } - - ++couple; - } - - position++; - } - - return true; -} - -ID GameToX::is_game_finished() -{ - list<Score>::const_iterator score = couples_.begin(); - while (score != couples_.end()) { - if ((*score).second >= max_points_) - return (*score).first; - - ++score; - } - - return ID_NULL; -} - -ID GameToX::next_player(ID player) -{ - /* Converts a list of Score to a list of identificators */ - list<ID> couples; - list<Score>::const_iterator score = couples_.begin(); - while (score != couples_.end()) { - couples.push_back((*score).first); - ++score; - } - - list<ID> players; - if (!players_in_order(couples, &players)) - return ID_NULL; - - if (players.size() < 2) - return ID_NULL; - - list<ID>::const_iterator iter = players.begin(); - while (iter != players.end()) { - if (player == *iter) { - ++iter; - if (iter == players.end()) - iter = players.begin(); - return *iter; - } - ++iter; - } - - return ID_NULL; -} - -bool GameToX::configure(Core *core) +bool GameToX::configure(Core* core) { if (core == NULL) return false; @@ -142,7 +56,7 @@ /* Set the player who starts the hand */ list<ID> players; - if (!players_in_order(couples, &players)) + if (!players_in_order_(couples, &players)) return false; player_starts_hand_ = *(players.begin()); @@ -152,7 +66,7 @@ return true; } -bool GameToX::next_hand(ID hand, list<ID> *players) +bool GameToX::next_hand(ID hand, list<ID>* players) { /* Only a hand at the time */ if (hand == ID_NULL || hand_ != ID_NULL) @@ -161,7 +75,7 @@ list<ID> couples; bool exit_status = core_->couples_in_game(id(), &couples); if (exit_status) - exit_status = players_in_order(couples, players); + exit_status = players_in_order_(couples, players); if (exit_status) hand_ = hand; @@ -198,7 +112,7 @@ } /* Next turn */ - player_starts_hand_ = next_player(player_starts_hand_); + player_starts_hand_ = next_player_(player_starts_hand_); hand_ = ID_NULL; @@ -214,14 +128,14 @@ return max_points_; } -void GameToX::score_board(list<Score> *score) +void GameToX::score_board(list<Score>* score) { *score = couples_; } ID GameToX::next_turn() { - if (is_game_finished() != ID_NULL) + if (is_game_finished_() != ID_NULL) return false; return player_starts_hand_; @@ -229,10 +143,96 @@ ID GameToX::winner() { - return is_game_finished(); + return is_game_finished_(); } bool GameToX::is_finished() { - return is_game_finished() != ID_NULL; + return is_game_finished_() != ID_NULL; +} + +ID GameToX::player_in_position_(ID couple, unsigned long position) +{ + list<ID> players; + if (!core_->players_in_couple(couple, &players)) + return ID_NULL; + + if (position >= players.size()) + return ID_NULL; + + list<ID>::const_iterator player = players.begin(); + while (position > 0) { + ++player; + position--; + } + + return *player; +} + +bool GameToX::players_in_order_(list<ID> couples, list<ID>* players) +{ + bool continue_bucle = true; + unsigned long position = 0; + while (continue_bucle) { + continue_bucle = false; + + list<ID>::const_iterator couple = couples.begin(); + while (couple != couples.end()) { + ID id = player_in_position_(*couple, position); + if (id != ID_NULL) { + continue_bucle = true; + players->push_back(id); + } + + ++couple; + } + + position++; + } + + return true; +} + +ID GameToX::is_game_finished_() +{ + list<Score>::const_iterator score = couples_.begin(); + while (score != couples_.end()) { + if ((*score).second >= max_points_) + return (*score).first; + + ++score; + } + + return ID_NULL; +} + +ID GameToX::next_player_(ID player) +{ + /* Converts a list of Score to a list of identificators */ + list<ID> couples; + list<Score>::const_iterator score = couples_.begin(); + while (score != couples_.end()) { + couples.push_back((*score).first); + ++score; + } + + list<ID> players; + if (!players_in_order_(couples, &players)) + return ID_NULL; + + if (players.size() < 2) + return ID_NULL; + + list<ID>::const_iterator iter = players.begin(); + while (iter != players.end()) { + if (player == *iter) { + ++iter; + if (iter == players.end()) + iter = players.begin(); + return *iter; + } + ++iter; + } + + return ID_NULL; } Index: to20_module.cpp =================================================================== RCS file: /cvsroot/dmn/dmn/src/Game/to20_module.cpp,v retrieving revision 1.1 retrieving revision 1.2 diff -u -d -r1.1 -r1.2 --- to20_module.cpp 26 Dec 2003 20:09:13 -0000 1.1 +++ to20_module.cpp 17 Mar 2004 04:48:24 -0000 1.2 @@ -28,12 +28,12 @@ using namespace dmn; -Module *Module_init() +Module* Module_init() { return new GameTo20; } -void Module_end(Module *module) +void Module_end(Module* module) { delete (GameTo20*) module; } Index: to30_module.cpp =================================================================== RCS file: /cvsroot/dmn/dmn/src/Game/to30_module.cpp,v retrieving revision 1.1 retrieving revision 1.2 diff -u -d -r1.1 -r1.2 --- to30_module.cpp 26 Dec 2003 20:09:13 -0000 1.1 +++ to30_module.cpp 17 Mar 2004 04:48:39 -0000 1.2 @@ -28,12 +28,12 @@ using namespace dmn; -Module *Module_init() +Module* Module_init() { return new GameTo30; } -void Module_end(Module *module) +void Module_end(Module* module) { delete (GameTo30*) module; } |
|
From: Xos? O. <xos...@us...> - 2004-03-17 04:58:05
|
Update of /cvsroot/dmn/dmn/src/Player In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv7239/src/Player Modified Files: qt.h qt_domino.cpp qt_domino.h qt_domino_progress.h qt_dominoes.h qt_image.cpp qt_image.h qt_mainwidget.cpp qt_mainwidget.h stupid.cpp stupid.h text.cpp text.h text_module.cpp Log Message: Now all the code follow the coding style (doc/CodingStyle) Index: qt_domino.h =================================================================== RCS file: /cvsroot/dmn/dmn/src/Player/qt_domino.h,v retrieving revision 1.4 retrieving revision 1.5 diff -u -d -r1.4 -r1.5 --- qt_domino.h 26 Dec 2003 20:09:14 -0000 1.4 +++ qt_domino.h 17 Mar 2004 04:48:40 -0000 1.5 @@ -38,7 +38,9 @@ */ class QtDomino: public QVBox { - Q_OBJECT public: + Q_OBJECT + + public: /** * Constructor * @@ -58,6 +60,12 @@ */ Domino domino() const; + signals: + /** + * One of the halfs if pushed + */ + void halfPushed(Domino, HalfDomino); + private: Domino domino_; @@ -71,12 +79,6 @@ * Push the second half */ void half2Pushed(); - - signals: - /** - * One of the halfs if pushed - */ - void halfPushed(Domino, HalfDomino); }; }; Index: qt_mainwidget.h =================================================================== RCS file: /cvsroot/dmn/dmn/src/Player/qt_mainwidget.h,v retrieving revision 1.4 retrieving revision 1.5 diff -u -d -r1.4 -r1.5 --- qt_mainwidget.h 26 Dec 2003 20:09:14 -0000 1.4 +++ qt_mainwidget.h 17 Mar 2004 04:48:40 -0000 1.5 @@ -40,7 +40,9 @@ */ class QtMainWidget: public QWidget { - Q_OBJECT public: + Q_OBJECT + + public: /** * Constructor * @@ -51,7 +53,7 @@ * @param name name of the widget */ QtMainWidget(Player* player, Core* core, Dominoes dominoes, - QWidget* parent = 0, const char *name = NULL); + QWidget* parent = 0, const char* name = NULL); /** * Get the domino played by the player @@ -62,8 +64,8 @@ int dominoPlayed(Domino* domino, HalfDomino* half); private slots: - void dominoPlayed(Domino domino, HalfDomino half); - void pass(); + void dominoPlayed_(Domino domino, HalfDomino half); + void pass_(); private: bool played_; Index: qt_image.h =================================================================== RCS file: /cvsroot/dmn/dmn/src/Player/qt_image.h,v retrieving revision 1.3 retrieving revision 1.4 diff -u -d -r1.3 -r1.4 --- qt_image.h 26 Dec 2003 20:09:14 -0000 1.3 +++ qt_image.h 17 Mar 2004 04:48:40 -0000 1.4 @@ -61,8 +61,8 @@ void paintEvent(QPaintEvent*); private: - QPixmap pixmap; - double scale_x, scale_y; + QPixmap pixmap_; + double scale_x_, scale_y_; }; }; Index: qt_image.cpp =================================================================== RCS file: /cvsroot/dmn/dmn/src/Player/qt_image.cpp,v retrieving revision 1.3 retrieving revision 1.4 diff -u -d -r1.3 -r1.4 --- qt_image.cpp 26 Dec 2003 20:09:14 -0000 1.3 +++ qt_image.cpp 17 Mar 2004 04:48:40 -0000 1.4 @@ -32,20 +32,20 @@ QtImage::QtImage(const QString& filename, QWidget* parent, const char* name) : QWidget(parent, name) { - scale_x = 1; - scale_y = 1; + scale_x_ = 1; + scale_y_ = 1; if (QFile::exists(filename)) { - pixmap.load(filename); + pixmap_.load(filename); } - setFixedSize(pixmap.width(), pixmap.height()); + setFixedSize(pixmap_.width(), pixmap_.height()); } void QtImage::setSize(int w, int h) { - scale_x = (double) w / pixmap.width(); - scale_y = (double) h / pixmap.height(); + scale_x_ = (double) w / pixmap_.width(); + scale_y_ = (double) h / pixmap_.height(); setFixedSize(w, h); } @@ -54,7 +54,7 @@ { QPainter* painter = new QPainter(this); - painter->scale(scale_x, scale_y); - painter->drawPixmap(0, 0, pixmap); + painter->scale(scale_x_, scale_y_); + painter->drawPixmap(0, 0, pixmap_); painter->end(); } Index: qt_domino_progress.h =================================================================== RCS file: /cvsroot/dmn/dmn/src/Player/qt_domino_progress.h,v retrieving revision 1.5 retrieving revision 1.6 diff -u -d -r1.5 -r1.6 --- qt_domino_progress.h 26 Dec 2003 20:09:14 -0000 1.5 +++ qt_domino_progress.h 17 Mar 2004 04:48:40 -0000 1.6 @@ -43,7 +43,9 @@ */ class QtDominoProgress: public QHBox { - Q_OBJECT public: + Q_OBJECT + + public: /** * Constructor * Index: qt_dominoes.h =================================================================== RCS file: /cvsroot/dmn/dmn/src/Player/qt_dominoes.h,v retrieving revision 1.4 retrieving revision 1.5 diff -u -d -r1.4 -r1.5 --- qt_dominoes.h 26 Dec 2003 20:09:14 -0000 1.4 +++ qt_dominoes.h 17 Mar 2004 04:48:40 -0000 1.5 @@ -38,7 +38,9 @@ */ class QtDominoes: public QWidget { - Q_OBJECT public: + Q_OBJECT + + public: /** * Constructor * @@ -49,7 +51,7 @@ * @param name name of the widget */ QtDominoes(Player* player, Core* core, Dominoes dominoes, - QWidget* parent = NULL, const char *name = NULL); + QWidget* parent = NULL, const char* name = NULL); signals: /** Index: text_module.cpp =================================================================== RCS file: /cvsroot/dmn/dmn/src/Player/text_module.cpp,v retrieving revision 1.1 retrieving revision 1.2 diff -u -d -r1.1 -r1.2 --- text_module.cpp 26 Dec 2003 20:09:14 -0000 1.1 +++ text_module.cpp 17 Mar 2004 04:48:40 -0000 1.2 @@ -28,12 +28,12 @@ using namespace dmn; -Module *Module_init() +Module* Module_init() { return new PlayerText(); } -void Module_end(Module *module) +void Module_end(Module* module) { delete (PlayerText*) module; } Index: text.cpp =================================================================== RCS file: /cvsroot/dmn/dmn/src/Player/text.cpp,v retrieving revision 1.2 retrieving revision 1.3 diff -u -d -r1.2 -r1.3 --- text.cpp 30 Dec 2003 09:14:17 -0000 1.2 +++ text.cpp 17 Mar 2004 04:48:40 -0000 1.3 @@ -43,7 +43,60 @@ is_configured_ = false; } -bool PlayerText::can_play() +bool PlayerText::configure(Core* core) +{ + if (core == NULL) + return false; + + core_ = core; + + if (is_configured_) + while (dominoes_.erase(dominoes_[0])) + ; + else + is_configured_ = true; + + hand_id_ = core_->hand_of_player(id()); + + return true; +} + +void PlayerText::set_name(string name) +{ + name_ = name; +} + +string PlayerText::name() +{ + return name_; +} + +bool PlayerText::is_interactive() +{ + return true; +} + +void PlayerText::set_shuffled_tile(Domino domino) +{ + dominoes_.insert(domino); +} + +bool PlayerText::domino_to_play(Domino* domino, HalfDomino* half) +{ + return select_domino_(domino, half); +} + +void PlayerText::set_domino_played(ID id, Domino domino, HalfDomino half) +{ + if (Module::id() == id) + dominoes_.erase(domino); +} + +void PlayerText::set_player_pass(ID id, bool domino_shuffled) +{ +} + +bool PlayerText::can_play_() { unsigned long size = dominoes_.size(), i; for (i = 0; i < size; i++) { @@ -58,11 +111,11 @@ return false; } -void PlayerText::show_dominoes() +void PlayerText::show_dominoes_() { puts(_("You have these dominoes:")); printf(_("0. PASS")); - if (!can_play()) + if (!can_play_()) printf(" <--"); putchar('\n'); unsigned long size = dominoes_.size(), i; @@ -78,10 +131,10 @@ } } -void PlayerText::show_count_dominoes(Dominoes dominoes, ID hand_id) +void PlayerText::show_count_dominoes_(Dominoes dominoes, ID hand_id) { int max_value = core_->max_half_value_in_hand(hand_id); - int *halfs = new int[max_value]; + int* halfs = new int[max_value]; unsigned long i; for (i = 0; i <= max_value; i++) halfs[i] = 0; @@ -104,15 +157,15 @@ delete[] halfs; } -bool PlayerText::select_domino(Domino* domino, HalfDomino* half) +bool PlayerText::select_domino_(Domino* domino, HalfDomino* half) { int number_domino, half1, half2; do { /* Select domino */ do { - show_dominoes(); - show_count_dominoes(dominoes_, hand_id_); + show_dominoes_(); + show_count_dominoes_(dominoes_, hand_id_); printf(_("%s, which domino to play? [0-%lu] "), name_.c_str(), dominoes_.size()); fflush(stdout); @@ -172,56 +225,3 @@ return 1; } - -bool PlayerText::configure(Core *core) -{ - if (core == NULL) - return false; - - core_ = core; - - if (is_configured_) - while (dominoes_.erase(dominoes_[0])) - ; - else - is_configured_ = true; - - hand_id_ = core_->hand_of_player(id()); - - return true; -} - -void PlayerText::set_name(string name) -{ - name_ = name; -} - -string PlayerText::name() -{ - return name_; -} - -bool PlayerText::is_interactive() -{ - return true; -} - -void PlayerText::set_shuffled_tile(Domino domino) -{ - dominoes_.insert(domino); -} - -bool PlayerText::domino_to_play(Domino *domino, HalfDomino *half) -{ - return select_domino(domino, half); -} - -void PlayerText::set_domino_played(ID id, Domino domino, HalfDomino half) -{ - if (Module::id() == id) - dominoes_.erase(domino); -} - -void PlayerText::set_player_pass(ID id, bool domino_shuffled) -{ -} Index: qt_mainwidget.cpp =================================================================== RCS file: /cvsroot/dmn/dmn/src/Player/qt_mainwidget.cpp,v retrieving revision 1.6 retrieving revision 1.7 diff -u -d -r1.6 -r1.7 --- qt_mainwidget.cpp 26 Dec 2003 20:09:14 -0000 1.6 +++ qt_mainwidget.cpp 17 Mar 2004 04:48:40 -0000 1.7 @@ -74,14 +74,14 @@ this); QtDominoes* doms = new QtDominoes(player, core, dominoes, groupdominoes); connect(doms, SIGNAL(dominoPlayed(Domino, HalfDomino)), this, - SLOT(dominoPlayed(Domino, HalfDomino))); + SLOT(dominoPlayed_(Domino, HalfDomino))); connect(doms, SIGNAL(dominoPlayed(Domino, HalfDomino)), qApp, SLOT(quit())); QPushButton* pass = new QPushButton(QString::fromUtf8(_("Pass")), groupdominoes); pass->adjustSize(); pass->setFixedSize(pass->width(), pass->height()); - connect(pass, SIGNAL(clicked()), this, SLOT(pass())); + connect(pass, SIGNAL(clicked()), this, SLOT(pass_())); connect(pass, SIGNAL(clicked()), qApp, SLOT(quit())); groupdominoes->adjustSize(); @@ -107,14 +107,14 @@ return true; } -void QtMainWidget::dominoPlayed(Domino domino, HalfDomino half) +void QtMainWidget::dominoPlayed_(Domino domino, HalfDomino half) { played_ = true; domino_ = domino; half_ = half; } -void QtMainWidget::pass() +void QtMainWidget::pass_() { played_ = false; } Index: stupid.h =================================================================== RCS file: /cvsroot/dmn/dmn/src/Player/stupid.h,v retrieving revision 1.1 retrieving revision 1.2 diff -u -d -r1.1 -r1.2 --- stupid.h 26 Dec 2003 20:09:14 -0000 1.1 +++ stupid.h 17 Mar 2004 04:48:40 -0000 1.2 @@ -40,14 +40,6 @@ */ class PlayerStupid: public Player { - private: - Core* core_; // Core - ID hand_id_; // Identificator of the hand where the players - // plays - std::string name_; // Player's name - Dominoes dominoes_; // Player's dominoes - bool is_configured_; // Module configured? - public: /** * Constructor @@ -62,6 +54,14 @@ bool domino_to_play(Domino* domino, HalfDomino* half); void set_domino_played(ID id, Domino domino, HalfDomino half); void set_player_pass(ID id, bool domino_shuffled); + + private: + Core* core_; // Core + ID hand_id_; // Identificator of the hand where the player + // plays + std::string name_; // Player's name + Dominoes dominoes_; // Player's dominoes + bool is_configured_; // Module configured? }; }; Index: text.h =================================================================== RCS file: /cvsroot/dmn/dmn/src/Player/text.h,v retrieving revision 1.1 retrieving revision 1.2 diff -u -d -r1.1 -r1.2 --- text.h 26 Dec 2003 20:09:14 -0000 1.1 +++ text.h 17 Mar 2004 04:48:40 -0000 1.2 @@ -36,26 +36,41 @@ */ class PlayerText: public Player { + public: + /** + * Constructor + */ + PlayerText(); + + bool configure(Core* core); + void set_name(std::string name); + std::string name(); + bool is_interactive(); + void set_shuffled_tile(Domino domino); + bool domino_to_play(Domino* domino, HalfDomino* half); + void set_domino_played(ID id, Domino domino, HalfDomino half); + void set_player_pass(ID id, bool domino_shuffled); + private: - Core* core_; // Core - ID hand_id_; // Identificator of the hand where the players - // plays + Core* core_; // Core + ID hand_id_; // Identificator of the hand where the players + // plays std::string name_; // Player's name dmn::Dominoes dominoes_; // Player's dominoes - bool is_configured_; // true -> Module configured, - // false -> Module not configured + bool is_configured_; // true -> Module configured, + // false -> Module not configured /** * Can the player play? * * @return true if the player can play or false if not */ - bool can_play(); + bool can_play_(); /** * Show the dominoes with the order */ - void show_dominoes(); + void show_dominoes_(); /** * Count the number of each half that there are in the list of dominoes @@ -63,7 +78,7 @@ * @param dominoes list of dominoes * @param hand_id identificator of the hand where to play */ - void show_count_dominoes(Dominoes dominoes, ID hand_id); + void show_count_dominoes_(Dominoes dominoes, ID hand_id); /** * Select the domino to play @@ -73,22 +88,7 @@ * * @return true if the player plays a domino or false if pass */ - bool select_domino(Domino* domino, HalfDomino* half); - - public: - /** - * Constructor - */ - PlayerText(); - - bool configure(Core *core); - void set_name(std::string name); - std::string name(); - bool is_interactive(); - void set_shuffled_tile(Domino domino); - bool domino_to_play(Domino *domino, HalfDomino *half); - void set_domino_played(ID id, Domino domino, HalfDomino half); - void set_player_pass(ID id, bool domino_shuffled); + bool select_domino_(Domino* domino, HalfDomino* half); }; }; Index: qt_domino.cpp =================================================================== RCS file: /cvsroot/dmn/dmn/src/Player/qt_domino.cpp,v retrieving revision 1.6 retrieving revision 1.7 diff -u -d -r1.6 -r1.7 --- qt_domino.cpp 26 Dec 2003 20:09:14 -0000 1.6 +++ qt_domino.cpp 17 Mar 2004 04:48:40 -0000 1.7 @@ -51,7 +51,7 @@ QPushButton* but1 = new QPushButton(QString::number(domino.half1().half()), this); but1->setAutoResize(true); - connect(but1, SIGNAL(clicked()), this, SLOT(half1Pushed())); + connect(but1, SIGNAL(clicked()), this, SLOT(half1Pushed_())); } if (domino.half1() != domino.half2() && core->domino_playable_in_hand(core->hand_of_player(player->id()), @@ -60,7 +60,7 @@ QPushButton *but2 = new QPushButton(QString::number(domino.half2().half()), this); but2->setAutoResize(true); - connect(but2, SIGNAL(clicked()), this, SLOT(half2Pushed())); + connect(but2, SIGNAL(clicked()), this, SLOT(half2Pushed_())); } adjustSize(); @@ -71,12 +71,12 @@ return domino_; } -void QtDomino::half1Pushed() +void QtDomino::half1Pushed_() { emit halfPushed(domino_, domino_.half1()); } -void QtDomino::half2Pushed() +void QtDomino::half2Pushed_() { emit halfPushed(domino_, domino_.half2()); } Index: stupid.cpp =================================================================== RCS file: /cvsroot/dmn/dmn/src/Player/stupid.cpp,v retrieving revision 1.1 retrieving revision 1.2 diff -u -d -r1.1 -r1.2 --- stupid.cpp 26 Dec 2003 20:09:14 -0000 1.1 +++ stupid.cpp 17 Mar 2004 04:48:40 -0000 1.2 @@ -41,7 +41,7 @@ is_configured_ = 0; } -bool PlayerStupid::configure(Core *core) +bool PlayerStupid::configure(Core* core) { if (core == NULL) return false; @@ -79,7 +79,7 @@ dominoes_.insert(domino); } -bool PlayerStupid::domino_to_play(Domino *domino, HalfDomino *half) +bool PlayerStupid::domino_to_play(Domino* domino, HalfDomino* half) { unsigned long i, size = dominoes_.size(); for (i = 0; i < size; i++) { Index: qt.h =================================================================== RCS file: /cvsroot/dmn/dmn/src/Player/qt.h,v retrieving revision 1.1 retrieving revision 1.2 diff -u -d -r1.1 -r1.2 --- qt.h 26 Dec 2003 20:09:14 -0000 1.1 +++ qt.h 17 Mar 2004 04:48:40 -0000 1.2 @@ -39,16 +39,6 @@ */ class PlayerQt: public Player { - private: - Core* core_; // Core - ID hand_id_; // Identificator of the hand where the players - // plays - std::string name_; // Player's name - dmn::Dominoes dominoes_; // Player's dominoes - bool is_configured_; // true -> Module configured, - // false -> Module not configured - QPoint position_; // Window position - public: /** * Constructor @@ -63,6 +53,16 @@ bool domino_to_play(Domino* domino, HalfDomino* half); void set_domino_played(ID id, Domino domino, HalfDomino half); void set_player_pass(ID id, bool domino_shuffled); + + private: + Core* core_; // Core + ID hand_id_; // Identificator of the hand where the players + // plays + std::string name_; // Player's name + dmn::Dominoes dominoes_; // Player's dominoes + bool is_configured_; // true -> Module configured, + // false -> Module not configured + QPoint position_; // Window position }; }; |
|
From: Xos? O. <xos...@us...> - 2004-03-17 04:58:05
|
Update of /cvsroot/dmn/dmn/src/Tournament In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv7239/src/Tournament Modified Files: cup.cpp cup.h Log Message: Now all the code follow the coding style (doc/CodingStyle) Index: cup.cpp =================================================================== RCS file: /cvsroot/dmn/dmn/src/Tournament/cup.cpp,v retrieving revision 1.1 retrieving revision 1.2 diff -u -d -r1.1 -r1.2 --- cup.cpp 26 Dec 2003 20:09:14 -0000 1.1 +++ cup.cpp 17 Mar 2004 04:48:40 -0000 1.2 @@ -39,74 +39,7 @@ set_desc(_("Cup Tournament")); } -bool TournamentCup::teams_in_order(list<ID> teams, list<data_t> *order) -{ - list<ID>::const_iterator team = teams.begin(); - while (team != teams.end()) { - data_t aux; - aux.team1 = *team; - ++team; - if (team != teams.end()) { - aux.team2 = *team; - } else - aux.team2 = ID_NULL; - aux.number_couple = 0; - aux.result = 0; - - order->push_back(aux); - - ++team; - } - - return true; -} - -/** - * Returns the couple of the team in the position position - * - * @param team identificators ot the team - * @param position position of the couple - * - * @return the identificator or ID_NULL if error - */ -ID TournamentCup::couple_in_position(ID team, unsigned long position) -{ - list<ID> couples; - if (!core_->couples_in_team(team, &couples)) - return ID_NULL; - - if (couples.size() < position) - return ID_NULL; - - list<ID>::iterator iter = couples.begin(); - while (position > 0) { - ++iter; - position--; - } - - return *iter; -} - -/** - * Search a team in the data_t - * - * @param team team to search - * - * @return the position of the data_t or NULL if not exist - */ -TournamentCup::data_t *TournamentCup::search_team(ID team) -{ - list<data_t>::iterator iter = teams_.begin(); - while (iter != teams_.end()) { - if ((*iter).team1 == team || (*iter).team2 == team) - return &(*iter); - ++iter; - } - - return NULL; -} - -bool TournamentCup::configure(Core *core) +bool TournamentCup::configure(Core* core) { if (core == NULL) return false; @@ -116,7 +49,7 @@ if (!core_->teams_in_tournament(id(), &teams)) return false; - if (!teams_in_order(teams, &teams_)) + if (!teams_in_order_(teams, &teams_)) return false; match_ = ID_NULL; @@ -124,7 +57,7 @@ return true; } -bool TournamentCup::next_match(ID match, list<ID> *couples) +bool TournamentCup::next_match(ID match, list<ID>* couples) { /* Only a match at the time */ if (match == ID_NULL || match_ != ID_NULL) @@ -134,17 +67,17 @@ if (next_eliminatoria_.size() == 1) return false; - if (!teams_in_order(next_eliminatoria_, &teams_)) + if (!teams_in_order_(next_eliminatoria_, &teams_)) return false; } list<data_t>::iterator iter = teams_.begin(); - ID id = couple_in_position((*iter).team1, (*iter).number_couple); + ID id = couple_in_position_((*iter).team1, (*iter).number_couple); if (id == ID_NULL) return false; couples->push_back(id); - id = couple_in_position((*iter).team2, (*iter).number_couple); + id = couple_in_position_((*iter).team2, (*iter).number_couple); if (id == ID_NULL) return false; couples->push_back(id); @@ -161,7 +94,7 @@ if (match == ID_NULL || match_ != match) return false; - data_t *aux = search_team(core_->team_of_couple(couple_winner)); + data_t* aux = search_team_(core_->team_of_couple(couple_winner)); if (aux == NULL) return false; @@ -194,7 +127,7 @@ return true; } -bool TournamentCup::classification(list<ID> *teams) +bool TournamentCup::classification(list<ID>* teams) { list<ID>::const_iterator team = next_eliminatoria_.begin(); while (team != next_eliminatoria_.end()) { @@ -218,3 +151,55 @@ { return teams_.empty() && next_eliminatoria_.size() == 1; } + +bool TournamentCup::teams_in_order_(list<ID> teams, list<data_t>* order) +{ + list<ID>::const_iterator team = teams.begin(); + while (team != teams.end()) { + data_t aux; + aux.team1 = *team; + ++team; + if (team != teams.end()) { + aux.team2 = *team; + } else + aux.team2 = ID_NULL; + aux.number_couple = 0; + aux.result = 0; + + order->push_back(aux); + + ++team; + } + + return true; +} + +ID TournamentCup::couple_in_position_(ID team, unsigned long position) +{ + list<ID> couples; + if (!core_->couples_in_team(team, &couples)) + return ID_NULL; + + if (couples.size() < position) + return ID_NULL; + + list<ID>::iterator iter = couples.begin(); + while (position > 0) { + ++iter; + position--; + } + + return *iter; +} + +TournamentCup::data_t* TournamentCup::search_team_(ID team) +{ + list<data_t>::iterator iter = teams_.begin(); + while (iter != teams_.end()) { + if ((*iter).team1 == team || (*iter).team2 == team) + return &(*iter); + ++iter; + } + + return NULL; +} Index: cup.h =================================================================== RCS file: /cvsroot/dmn/dmn/src/Tournament/cup.h,v retrieving revision 1.1 retrieving revision 1.2 diff -u -d -r1.1 -r1.2 --- cup.h 26 Dec 2003 20:09:14 -0000 1.1 +++ cup.h 17 Mar 2004 04:48:41 -0000 1.2 @@ -44,6 +44,19 @@ */ class TournamentCup: public Tournament { + public: + /** + * Constructor + */ + TournamentCup(); + + bool configure(Core* core); + bool next_match(ID match, std::list<ID>* couples); + bool set_match_winner(ID match, ID couple_winner); + bool classification(std::list<ID>* teams); + ID winner(); + bool is_finished(); + private: struct data_t { ID team1, team2; @@ -66,7 +79,7 @@ * * @return true if all was ok, else false */ - bool teams_in_order(std::list<ID> teams, std::list<data_t> *order); + bool teams_in_order_(std::list<ID> teams, std::list<data_t>* order); /** * Returns the couple of the team in the position position @@ -76,7 +89,7 @@ * * @return the identificator or DMN_ID_NULL if error */ - ID couple_in_position(ID team, unsigned long position); + ID couple_in_position_(ID team, unsigned long position); /** * Search a team in the data_t @@ -85,20 +98,7 @@ * * @return the position of the data_t or NULL if not exist */ - data_t *search_team(ID team); - - public: - /** - * Constructor - */ - TournamentCup(); - - bool configure(Core *core); - bool next_match(ID match, std::list<ID> *couples); - bool set_match_winner(ID match, ID couple_winner); - bool classification(std::list<ID> *teams); - ID winner(); - bool is_finished(); + data_t* search_team_(ID team); }; }; |
|
From: Xos? O. <xos...@us...> - 2004-03-17 04:58:04
|
Update of /cvsroot/dmn/dmn/src/Match In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv7239/src/Match Modified Files: to1.h to1_module.cpp toX.h Log Message: Now all the code follow the coding style (doc/CodingStyle) Index: toX.h =================================================================== RCS file: /cvsroot/dmn/dmn/src/Match/toX.h,v retrieving revision 1.1 retrieving revision 1.2 diff -u -d -r1.1 -r1.2 --- toX.h 26 Dec 2003 20:09:14 -0000 1.1 +++ toX.h 17 Mar 2004 04:48:40 -0000 1.2 @@ -36,12 +36,6 @@ */ class MatchToX: public Match { - private: - Core *core_; // Core - ID game_; // game played now - std::list<Score> couples_; // List of Score - Points max_games_; // Games to win - public: /** * Constructor @@ -57,6 +51,12 @@ void score_board(std::list<Score>* score); ID winner(); bool is_finished(); + + private: + Core* core_; // Core + ID game_; // game played now + std::list<Score> couples_; // List of Score + Points max_games_; // Games to win }; }; Index: to1_module.cpp =================================================================== RCS file: /cvsroot/dmn/dmn/src/Match/to1_module.cpp,v retrieving revision 1.1 retrieving revision 1.2 diff -u -d -r1.1 -r1.2 --- to1_module.cpp 26 Dec 2003 20:09:14 -0000 1.1 +++ to1_module.cpp 17 Mar 2004 04:48:40 -0000 1.2 @@ -28,12 +28,12 @@ using namespace dmn; -Module *Module_init() +Module* Module_init() { return new MatchTo1; } -void Module_end(Module *module) +void Module_end(Module* module) { delete (MatchTo1*) module; } Index: to1.h =================================================================== RCS file: /cvsroot/dmn/dmn/src/Match/to1.h,v retrieving revision 1.1 retrieving revision 1.2 diff -u -d -r1.1 -r1.2 --- to1.h 26 Dec 2003 20:09:14 -0000 1.1 +++ to1.h 17 Mar 2004 04:48:40 -0000 1.2 @@ -33,13 +33,13 @@ * Match module to 1 games */ class MatchTo1: public MatchToX - { - public: - /** - * Constructor - */ - MatchTo1(); - }; + { + public: + /** + * Constructor + */ + MatchTo1(); + }; }; #endif // MATCH_TO1_H |
|
From: Xos? O. <xos...@us...> - 2004-03-17 04:58:04
|
Update of /cvsroot/dmn/dmn/src/Hand In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv7239/src/Hand Modified Files: default.cpp default.h default_module.cpp Log Message: Now all the code follow the coding style (doc/CodingStyle) Index: default.h =================================================================== RCS file: /cvsroot/dmn/dmn/src/Hand/default.h,v retrieving revision 1.1 retrieving revision 1.2 diff -u -d -r1.1 -r1.2 --- default.h 26 Dec 2003 20:09:13 -0000 1.1 +++ default.h 17 Mar 2004 04:48:40 -0000 1.2 @@ -43,13 +43,34 @@ */ class HandDefault: public Hand { + public: + /** + * Constructor + */ + HandDefault(); + + bool configure(Core* core); + ID player_who_started(); + void set_player_who_starts(ID player); + ID turn(); + int number_dominoes(); + HalfDomino max_half_value(); + int dominoes_played(Dominoes* dominoes); + int dominoes_has_player(ID player); + bool shuffle_tile(ID* player, Domino* domino); + bool domino_playable(ID player, Domino domino, HalfDomino half); + void set_play_domino(ID player, Domino domino, HalfDomino half); + bool set_player_pass(ID player, Domino* domino); + ID winner(Points* points); + bool is_finished(); + private: struct player_t { ID id; Dominoes dominoes; }; - Core *core_; // Core + Core* core_; // Core Dominoes dominoes_; // Dominoes not played Dominoes dominoes_played_; // Dominoes played ID player_who_started_; @@ -68,7 +89,7 @@ * * @return the number of dominoes */ - int calcule_number_dominoes(int max); + int calcule_number_dominoes_(int max); /** * Insert in the list all the dominoes @@ -77,7 +98,7 @@ * * @return true if all was ok, else false */ - bool fill_dominoes(Dominoes *dominoes); + bool fill_dominoes_(Dominoes* dominoes); /** * Return a random number betwen 0 and max (0 <= x < max) @@ -86,7 +107,7 @@ * * @return random number */ - int random_number(int max); + int random_number_(int max); /** * Search a id-player in data @@ -96,7 +117,7 @@ * @return the pointer of the player's data or NULL if the player was not * found */ - player_t *search_player(ID player); + player_t* search_player_(ID player); /** * Shuffle a random tile to a player @@ -106,7 +127,7 @@ * * @return true if all was ok, else false */ - bool shuffle_tile_to_player(ID player, Domino *domino); + bool shuffle_tile_to_player_(ID player, Domino* domino); /** * Remove a domino to a player @@ -116,7 +137,7 @@ * * @return true if all was ok, else false */ - bool remove_domino_to_player(ID player, Domino domino); + bool remove_domino_to_player_(ID player, Domino domino); /** * Count the points that has a player in his dominoes @@ -125,7 +146,7 @@ * * @return the points */ - Points count_points_of_player(player_t player); + Points count_points_of_player_(player_t player); /** * Count the points that has a couple in their dominoes @@ -135,7 +156,7 @@ * * @return the points */ - Points count_points_of_couple(std::list<player_t> players, ID couple); + Points count_points_of_couple_(std::list<player_t> players, ID couple); /** * Convert the points in the _real_ points @@ -144,7 +165,7 @@ * * @return the points normalized */ - Points normalize_points(Points points); + Points normalize_points_(Points points); /** * Insert a new player in the list of players @@ -154,7 +175,7 @@ * * @return true if all was ok, else false */ - bool new_player(std::list<player_t> *players, ID id); + bool new_player_(std::list<player_t>* players, ID id); /** * Check if the player can play or not @@ -164,14 +185,14 @@ * * @return true if the player can play or false if not */ - bool player_can_play(ID player, Dominoes dominoes); + bool player_can_play_(ID player, Dominoes dominoes); /** * Check if the hand is closed * * @return true if the hand is closed or false if not */ - bool is_closed(); + bool is_closed_(); /** * Player with less points in the hand @@ -180,7 +201,7 @@ * * @return the identificator of the player */ - ID player_with_less_points(std::list<player_t> players); + ID player_with_less_points_(std::list<player_t> players); /** * Couple with less points in the hand @@ -189,7 +210,7 @@ * * @return the identificator of the couple */ - ID couple_with_less_points(std::list<player_t> players); + ID couple_with_less_points_(std::list<player_t> players); /** * Player with less points in the Couple with less points in the hand @@ -198,7 +219,7 @@ * * @return the identificator of the player */ - ID player_couple_with_less_points(std::list<player_t> players); + ID player_couple_with_less_points_(std::list<player_t> players); /** * Count the points of the players @@ -207,7 +228,7 @@ * * @return the points */ - Points count_points_of_players(std::list<player_t> players); + Points count_points_of_players_(std::list<player_t> players); /** * First player in the list without dominoes @@ -216,7 +237,7 @@ * * @return the identificator of the player */ - ID player_without_dominoes(std::list<player_t> players); + ID player_without_dominoes_(std::list<player_t> players); /** * Search the highest double domino in the list @@ -226,7 +247,7 @@ * * @return true if a double is found or false if not */ - bool highest_double_domino(Dominoes dominoes, Domino *highest); + bool highest_double_domino_(Dominoes dominoes, Domino* highest); /** * Search the highest domino in the list @@ -236,7 +257,7 @@ * * @return true if a there are dominoes in the list or false if not */ - bool highest_single_domino(Dominoes dominoes, Domino *highest); + bool highest_single_domino_(Dominoes dominoes, Domino* highest); /** * Search the domino to start in the first hand of a game @@ -252,36 +273,15 @@ * @return true if a player/domino was found or false if there aren't * dominoes */ - bool domino_to_start(std::list<player_t> players, ID *player, - Domino *domino); + bool domino_to_start_(std::list<player_t> players, ID* player, + Domino* domino); /** * Next player to play * * @return the player's identificator of the next player */ - ID next_turn(); - - public: - /** - * Constructor - */ - HandDefault(); - - bool configure(Core *core); - ID player_who_started(); - void set_player_who_starts(ID player); - ID turn(); - int number_dominoes(); - HalfDomino max_half_value(); - int dominoes_played(Dominoes *dominoes); - int dominoes_has_player(ID player); - bool shuffle_tile(ID *player, Domino *domino); - bool domino_playable(ID player, Domino domino, HalfDomino half); - void set_play_domino(ID player, Domino domino, HalfDomino half); - bool set_player_pass(ID player, Domino *domino); - ID winner(Points *points); - bool is_finished(); + ID next_turn_(); }; }; Index: default.cpp =================================================================== RCS file: /cvsroot/dmn/dmn/src/Hand/default.cpp,v retrieving revision 1.3 retrieving revision 1.4 diff -u -d -r1.3 -r1.4 --- default.cpp 31 Dec 2003 22:51:44 -0000 1.3 +++ default.cpp 17 Mar 2004 04:48:40 -0000 1.4 @@ -49,7 +49,227 @@ is_configured_ = 0; } -int HandDefault::calcule_number_dominoes(int max) +bool HandDefault::configure(Core* core) +{ + if (core == NULL) + return false; + + core_ = core; + + if (is_configured_) { + // delete_players(&players_); + } else + is_configured_ = 1; + + /* Get the players from the hand_id (is a hard thing to do!) */ + list<ID> players; + if (!core_->players_in_hand(id(), &players)) + return false; + + struct timeval tv; + gettimeofday(&tv, NULL); + srand(tv.tv_usec); /* random number??? */ + dominoes_shuffled_ = false; + + fill_dominoes_(&dominoes_); + + list<ID>::const_iterator id = players.begin(); + while (id != players.end()) { + if (!new_player_(&players_, *id)) + return false; + ++id; + } + + first_hand_of_game_ = + core_->is_first_hand_of_game(core_->game_of_hand(Module::id()), + Module::id()); + + return true; +} + +ID HandDefault::player_who_started() +{ + return player_who_started_; +} + +void HandDefault::set_player_who_starts(ID player) +{ + player_who_started_ = player; + turn_ = player; +} + +ID HandDefault::turn() +{ + if (is_finished()) + return ID_NULL; + + return turn_; +} + +int HandDefault::number_dominoes() +{ + return calcule_number_dominoes_(MAX_HALF_VALUE + 1); +} + +HalfDomino HandDefault::max_half_value() +{ + return MAX_HALF_VALUE; +} + +int HandDefault::dominoes_played(Dominoes* dominoes) +{ + unsigned long size = dominoes_played_.size(), i; + for (i = 0; i < size; i++) + dominoes->insert(dominoes_played_[i]); + + return size; +} + +int HandDefault::dominoes_has_player(ID player) +{ + list<player_t>::const_iterator iter = players_.begin(); + while (iter != players_.end()) { + if ((*iter).id == player) + return (*iter).dominoes.size(); + + ++iter; + } + + return 0; +} + +bool HandDefault::shuffle_tile(ID* player, Domino* domino) +{ + if (dominoes_shuffled_) + return false; + + *player = turn_; + if (!shuffle_tile_to_player_(*player, domino)) + return false; + + /* Calculate the next turn */ + turn_ = next_turn_(); + + /* If the next player has all the dominoes, all the players has all the + dominoes */ + player_t* next_player = search_player_(turn_); + if (next_player->dominoes.size() == DOMINOES_BY_PLAYER) { + dominoes_shuffled_ = true; + if (first_hand_of_game_) + /* Search player who starts and the domino that must play */ + domino_to_start_(players_, &player_who_started_, &domino_started_); + } + + return true; +} + +bool HandDefault::domino_playable(ID player, Domino domino, HalfDomino half) +{ + if (turn_ != player || !dominoes_shuffled_) + return false; + + /* Check if the player has the domino */ + player_t* player_aux = search_player_(player); + if (!player_aux->dominoes.search(domino)) + return false; + + /* First domino of the hand */ + if (dominoes_played_.size() == 0) { + /* First hand of the game */ + if (first_hand_of_game_) + if (player_who_started_ != player || domino_started_ != domino) + return false; + + /* Other hand of the game */ + return true; + } + + /* Check if the domino which player wants to play can be played at begining + or at end */ + if (dominoes_played_[0].half1() == half) + return true; + if (dominoes_played_[dominoes_played_.size() - 1].half2() == half) + return true; + + return false; +} + +void HandDefault::set_play_domino(ID player, Domino domino, HalfDomino half) +{ + if (!domino_playable(player, domino, half)) + return; + + if (!dominoes_played_.insert_in_order(domino, half)) + return; + + /* Calculate the next turn */ + turn_ = next_turn_(); + + remove_domino_to_player_(player, domino); +} + +bool HandDefault::set_player_pass(ID player, Domino* domino) +{ + /* If player can play, do nothing */ + player_t* aux = search_player_(player); + if (aux == NULL) + return false; + if (player_can_play_(player, aux->dominoes)) + return false; + + if (dominoes_.size() == 0 || turn_ != player || + dominoes_played_.size() == 0) { + /* Calculate the next turn */ + turn_ = next_turn_(); + return false; + } + + return shuffle_tile_to_player_(player, domino); +} + +ID HandDefault::winner(Points* points) +{ + ID player; + if (is_closed_()) { + player = player_couple_with_less_points_(players_); + *points = count_points_of_players_(players_); + } else { + player = player_without_dominoes_(players_); + *points = count_points_of_players_(players_); + + if (player == ID_NULL) + return ID_NULL; + + player_t* pt_player = search_player_(player); + if (pt_player->dominoes.size() > 0) + return ID_NULL; + } + + /* If there aren't points, nobody wins */ + if (*points == 0) + player = ID_NULL; + + *points = normalize_points_(*points); + + return player; +} + +bool HandDefault::is_finished() +{ + if (is_closed_()) + return true; + + ID player = player_without_dominoes_(players_); + if (player == ID_NULL) + return false; + player_t* pt_player = search_player_(player); + if (pt_player->dominoes.size() > 0) + return false; + + return true; +} + +int HandDefault::calcule_number_dominoes_(int max) { int number = 0; @@ -61,7 +281,7 @@ return number; } -bool HandDefault::fill_dominoes(Dominoes *dominoes) +bool HandDefault::fill_dominoes_(Dominoes* dominoes) { for (int i = 0; i <= MAX_HALF_VALUE; i++) for (int j = i; j <= MAX_HALF_VALUE; j++) { @@ -72,12 +292,12 @@ return true; } -int HandDefault::random_number(int max) +int HandDefault::random_number_(int max) { return (int) (((float) max) * rand() / (RAND_MAX + 1.0)); } -HandDefault::player_t* HandDefault::search_player(ID player) +HandDefault::player_t* HandDefault::search_player_(ID player) { list<player_t>::iterator iter = players_.begin(); while (iter != players_.end()) { @@ -89,13 +309,13 @@ return NULL; } -bool HandDefault::shuffle_tile_to_player(ID player, Domino *domino) +bool HandDefault::shuffle_tile_to_player_(ID player, Domino* domino) { - player_t *address = search_player(player); + player_t* address = search_player_(player); if (address == NULL) return false; - int position = random_number(dominoes_.size()); + int position = random_number_(dominoes_.size()); *domino = dominoes_[position]; address->dominoes.insert(*domino); dominoes_.erase(*domino); @@ -103,16 +323,16 @@ return true; } -bool HandDefault::remove_domino_to_player(ID player, Domino domino) +bool HandDefault::remove_domino_to_player_(ID player, Domino domino) { - player_t *aux = search_player(player); + player_t* aux = search_player_(player); if (aux == NULL) return false; return aux->dominoes.erase(domino); } -Points HandDefault::count_points_of_player(player_t player) +Points HandDefault::count_points_of_player_(player_t player) { Points points = 0; @@ -123,14 +343,14 @@ return points; } -Points HandDefault::count_points_of_couple(list<player_t> players, ID couple) +Points HandDefault::count_points_of_couple_(list<player_t> players, ID couple) { Points points = 0; list<player_t>::const_iterator player = players.begin(); while (player != players.end()) { if (core_->couple_of_player((*player).id) == couple) - points += count_points_of_player(*player); + points += count_points_of_player_(*player); ++player; } @@ -138,7 +358,7 @@ return points; } -Points HandDefault::normalize_points(Points points) +Points HandDefault::normalize_points_(Points points) { if (points == 0) return 0; @@ -146,7 +366,7 @@ return (points - 1) / 10 + 1; } -bool HandDefault::new_player(list<player_t> *players, ID id) +bool HandDefault::new_player_(list<player_t>* players, ID id) { player_t player; player.id = id; @@ -156,7 +376,7 @@ return true; } -bool HandDefault::player_can_play(ID player, Dominoes dominoes) +bool HandDefault::player_can_play_(ID player, Dominoes dominoes) { unsigned long size = dominoes.size(), i; for (i = 0; i < size; i++) @@ -167,7 +387,7 @@ return false; } -bool HandDefault::is_closed() +bool HandDefault::is_closed_() { if (dominoes_.size() > 0) return false; @@ -178,7 +398,7 @@ while (player != players_.end()) { turn_ = (*player).id; if ((*player).dominoes.size() == 0 - || player_can_play((*player).id, (*player).dominoes)) { + || player_can_play_((*player).id, (*player).dominoes)) { turn_ = turn; return false; } @@ -191,14 +411,14 @@ return true; } -ID HandDefault::player_with_less_points(std::list<player_t> players) +ID HandDefault::player_with_less_points_(std::list<player_t> players) { ID player = ID_NULL; Points points_min = (Points) ~0; std::list<player_t>::const_iterator iter = players.begin(); while (iter != players.end()) { - Points points_aux = count_points_of_player(*iter); + Points points_aux = count_points_of_player_(*iter); if (points_aux < points_min) { points_min = points_aux; player = (*iter).id; @@ -211,7 +431,7 @@ return player; } -ID HandDefault::couple_with_less_points(list<player_t> players) +ID HandDefault::couple_with_less_points_(list<player_t> players) { ID couple = ID_NULL; Points points_min = (Points) ~0; @@ -221,7 +441,7 @@ while (player != players.end()) { ID couple_aux = core_->couple_of_player((*player).id); if (couple_aux != couple) { - Points points_aux = count_points_of_couple(players, couple_aux); + Points points_aux = count_points_of_couple_(players, couple_aux); if (points_aux < points_min) { points_min = points_aux; couple = couple_aux; @@ -239,9 +459,9 @@ return couple; } -ID HandDefault::player_couple_with_less_points(list<player_t> players) +ID HandDefault::player_couple_with_less_points_(list<player_t> players) { - ID couple = couple_with_less_points(players); + ID couple = couple_with_less_points_(players); if (couple == ID_NULL) return ID_NULL; @@ -254,7 +474,7 @@ ++iter; } - ID player = player_with_less_points(players_of_couple); + ID player = player_with_less_points_(players_of_couple); /* If the players have the same points, the first player is the "winner" */ if (player == ID_NULL) { iter = players.begin(); @@ -264,20 +484,20 @@ return player; } -Points HandDefault::count_points_of_players(list<player_t> players) +Points HandDefault::count_points_of_players_(list<player_t> players) { Points points = 0; list<player_t>::const_iterator player = players.begin(); while (player != players.end()) { - points += count_points_of_player(*player); + points += count_points_of_player_(*player); ++player; } return points; } -ID HandDefault::player_without_dominoes(list<player_t> players) +ID HandDefault::player_without_dominoes_(list<player_t> players) { list<player_t>::const_iterator player = players.begin(); while (player != players.end()) { @@ -289,7 +509,7 @@ return ID_NULL; } -bool HandDefault::highest_double_domino(Dominoes dominoes, Domino *highest) +bool HandDefault::highest_double_domino_(Dominoes dominoes, Domino* highest) { Points max_points = 0; @@ -308,7 +528,7 @@ return true; } -bool HandDefault::highest_single_domino(Dominoes dominoes, Domino *highest) +bool HandDefault::highest_single_domino_(Dominoes dominoes, Domino* highest) { Points max_points = 0; @@ -327,8 +547,8 @@ return true; } -bool HandDefault::domino_to_start(list<player_t> players, ID *player, - Domino *domino) +bool HandDefault::domino_to_start_(list<player_t> players, ID* player, + Domino* domino) { Points max_points = 0; *player = ID_NULL; @@ -337,7 +557,7 @@ list<player_t>::const_iterator iter = players.begin(); while (iter != players.end()) { Domino aux_domino; - if (highest_double_domino((*iter).dominoes, &aux_domino)) { + if (highest_double_domino_((*iter).dominoes, &aux_domino)) { Points aux_points = aux_domino.half1() + aux_domino.half2(); if (aux_points > max_points) { max_points = aux_points; @@ -356,7 +576,7 @@ iter = players.begin(); while (iter != players.end()) { Domino aux_domino; - if (highest_single_domino((*iter).dominoes, &aux_domino)) { + if (highest_single_domino_((*iter).dominoes, &aux_domino)) { Points aux_points = aux_domino.half1() + aux_domino.half2(); if (aux_points > max_points) { max_points = aux_points; @@ -371,7 +591,7 @@ return *player != ID_NULL; } -ID HandDefault::next_turn() +ID HandDefault::next_turn_() { list<player_t>::const_iterator player = players_.begin(); while (player != players_.end()) { @@ -387,223 +607,3 @@ return ID_NULL; } - -bool HandDefault::configure(Core *core) -{ - if (core == NULL) - return false; - - core_ = core; - - if (is_configured_) { - // delete_players(&players_); - } else - is_configured_ = 1; - - /* Get the players from the hand_id (is a hard thing to do!) */ - list<ID> players; - if (!core_->players_in_hand(id(), &players)) - return false; - - struct timeval tv; - gettimeofday(&tv, NULL); - srand(tv.tv_usec); /* random number??? */ - dominoes_shuffled_ = false; - - fill_dominoes(&dominoes_); - - list<ID>::const_iterator id = players.begin(); - while (id != players.end()) { - if (!new_player(&players_, *id)) - return false; - ++id; - } - - first_hand_of_game_ = - core_->is_first_hand_of_game(core_->game_of_hand(Module::id()), - Module::id()); - - return true; -} - -ID HandDefault::player_who_started() -{ - return player_who_started_; -} - -void HandDefault::set_player_who_starts(ID player) -{ - player_who_started_ = player; - turn_ = player; -} - -ID HandDefault::turn() -{ - if (is_finished()) - return ID_NULL; - - return turn_; -} - -int HandDefault::number_dominoes() -{ - return calcule_number_dominoes(MAX_HALF_VALUE + 1); -} - -HalfDomino HandDefault::max_half_value() -{ - return MAX_HALF_VALUE; -} - -int HandDefault::dominoes_played(Dominoes *dominoes) -{ - unsigned long size = dominoes_played_.size(), i; - for (i = 0; i < size; i++) - dominoes->insert(dominoes_played_[i]); - - return size; -} - -int HandDefault::dominoes_has_player(ID player) -{ - list<player_t>::const_iterator iter = players_.begin(); - while (iter != players_.end()) { - if ((*iter).id == player) - return (*iter).dominoes.size(); - - ++iter; - } - - return 0; -} - -bool HandDefault::shuffle_tile(ID *player, Domino *domino) -{ - if (dominoes_shuffled_) - return false; - - *player = turn_; - if (!shuffle_tile_to_player(*player, domino)) - return false; - - /* Calculate the next turn */ - turn_ = next_turn(); - - /* If the next player has all the dominoes, all the players has all the - dominoes */ - player_t *next_player = search_player(turn_); - if (next_player->dominoes.size() == DOMINOES_BY_PLAYER) { - dominoes_shuffled_ = true; - if (first_hand_of_game_) - /* Search player who starts and the domino that must play */ - domino_to_start(players_, &player_who_started_, &domino_started_); - } - - return true; -} - -bool HandDefault::domino_playable(ID player, Domino domino, HalfDomino half) -{ - if (turn_ != player || !dominoes_shuffled_) - return false; - - /* Check if the player has the domino */ - player_t *player_aux = search_player(player); - if (!player_aux->dominoes.search(domino)) - return false; - - /* First domino of the hand */ - if (dominoes_played_.size() == 0) { - /* First hand of the game */ - if (first_hand_of_game_) - if (player_who_started_ != player || domino_started_ != domino) - return false; - - /* Other hand of the game */ - return true; - } - - /* Check if the domino which player wants to play can be played at begining - or at end */ - if (dominoes_played_[0].half1() == half) - return true; - if (dominoes_played_[dominoes_played_.size() - 1].half2() == half) - return true; - - return false; -} - -void HandDefault::set_play_domino(ID player, Domino domino, HalfDomino half) -{ - if (!domino_playable(player, domino, half)) - return; - - if (!dominoes_played_.insert_in_order(domino, half)) - return; - - /* Calculate the next turn */ - turn_ = next_turn(); - - remove_domino_to_player(player, domino); -} - -bool HandDefault::set_player_pass(ID player, Domino *domino) -{ - /* If player can play, do nothing */ - player_t *aux = search_player(player); - if (aux == NULL) - return false; - if (player_can_play(player, aux->dominoes)) - return false; - - if (dominoes_.size() == 0 || turn_ != player || - dominoes_played_.size() == 0) { - /* Calculate the next turn */ - turn_ = next_turn(); - return false; - } - - return shuffle_tile_to_player(player, domino); -} - -ID HandDefault::winner(Points *points) -{ - ID player; - if (is_closed()) { - player = player_couple_with_less_points(players_); - *points = count_points_of_players(players_); - } else { - player = player_without_dominoes(players_); - *points = count_points_of_players(players_); - - if (player == ID_NULL) - return ID_NULL; - - player_t *pt_player = search_player(player); - if (pt_player->dominoes.size() > 0) - return ID_NULL; - } - - /* If there aren't points, nobody wins */ - if (*points == 0) - player = ID_NULL; - - *points = normalize_points(*points); - - return player; -} - -bool HandDefault::is_finished() -{ - if (is_closed()) - return true; - - ID player = player_without_dominoes(players_); - if (player == ID_NULL) - return false; - player_t *pt_player = search_player(player); - if (pt_player->dominoes.size() > 0) - return false; - - return true; -} Index: default_module.cpp =================================================================== RCS file: /cvsroot/dmn/dmn/src/Hand/default_module.cpp,v retrieving revision 1.1 retrieving revision 1.2 diff -u -d -r1.1 -r1.2 --- default_module.cpp 26 Dec 2003 20:09:13 -0000 1.1 +++ default_module.cpp 17 Mar 2004 04:48:40 -0000 1.2 @@ -30,12 +30,12 @@ using namespace dmn; -Module *Module_init() +Module* Module_init() { return new HandDefault; } -void Module_end(Module *module) +void Module_end(Module* module) { delete (HandDefault*) module; } |
|
From: Xos? O. <xos...@us...> - 2004-03-16 13:58:26
|
Update of /cvsroot/dmn/dmn In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv1928 Modified Files: TODO Log Message: Rewrited the TODO list Index: TODO =================================================================== RCS file: /cvsroot/dmn/dmn/TODO,v retrieving revision 1.2 retrieving revision 1.3 diff -u -d -r1.2 -r1.3 --- TODO 7 Jul 2003 11:31:59 -0000 1.2 +++ TODO 16 Mar 2004 13:49:02 -0000 1.3 @@ -1,37 +1,20 @@ DMN TODO List -1. Before 1.0: -Implementation: - Core Wed, 02 Jul 2003 04:01:07 +0200 - Config Wed, 02 Jul 2003 04:01:07 +0200 - Display Wed, 02 Jul 2003 04:01:07 +0200 - Match Wed, 02 Jul 2003 04:01:07 +0200 - Player Wed, 02 Jul 2003 04:01:07 +0200 - Hand Wed, 02 Jul 2003 04:01:07 +0200 - Sound Wed, 02 Jul 2003 04:01:07 +0200 - Tournament Wed, 02 Jul 2003 04:01:07 +0200 - -Documentation for interfaces: - Core Wed, 02 Jul 2003 04:01:07 +0200 - Config Wed, 02 Jul 2003 04:01:07 +0200 - Display Wed, 02 Jul 2003 04:01:07 +0200 - Match Wed, 02 Jul 2003 04:01:07 +0200 - Player Wed, 02 Jul 2003 04:01:07 +0200 - Hand Wed, 02 Jul 2003 04:01:07 +0200 - Sound Wed, 02 Jul 2003 04:01:07 +0200 - Tournament Wed, 02 Jul 2003 04:01:07 +0200 - -Graphical interfaces: - text Wed, 02 Jul 2003 04:01:07 +0200 - ncurses Wed, 02 Jul 2003 04:01:07 +0200 - SDL Wed, 02 Jul 2003 04:01:07 +0200 - -2. After 1.0: -Interfaces: - KDE Wed, 02 Jul 2003 04:01:07 +0200 - GNOME Wed, 02 Jul 2003 04:01:07 +0200 - Win32 Wed, 02 Jul 2003 04:01:07 +0200 +1. Before 0.5: +ii) Pass parameters to modules in command line and in configuration file: +$ dmn --MODULE_TYPE=MODULE:OPTION=NUMERIC_VALUE,OPTION="TEXT_VALUE" +iii) Thread safe modules. In Module add +void lock() +void unlock() +that need to be called by all the function members. +iv) Netgame using XML-RPC to comunicate the modules in the net. It's needed a server and client version for: Core, Player, Display, Sound -Other: - "Canalla" mode Wed, 02 Jul 2003 04:01:07 +0200 - Web management Wed, 02 Jul 2003 04:01:07 +0200 +2. After 0.5: +i) Qt interface (Display and Config) +ii) SDL interfaces (Player, Display and Config) +iii) ncurses interfaces (Player, Display and Config) +iv) KDE interfaces (Player, Display and Config) +v) GNOME interfaces (Player, Display and Config) +vi) Win32 interfaces (Player, Display and Config) +vii) "Canalla" mode suggested by Edu (unfair playing) +viii) Web management for championships |
|
From: Xos? O. <xos...@us...> - 2004-03-16 04:22:57
|
Update of /cvsroot/dmn/dmn In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv22489 Modified Files: clean_cvs Log Message: Remove the backup files: file~ and #file# Index: clean_cvs =================================================================== RCS file: /cvsroot/dmn/dmn/clean_cvs,v retrieving revision 1.2 retrieving revision 1.3 diff -u -d -r1.2 -r1.3 --- clean_cvs 23 Oct 2003 18:23:21 -0000 1.2 +++ clean_cvs 16 Mar 2004 04:13:42 -0000 1.3 @@ -1,9 +1,14 @@ #! /bin/sh -# Clean the cvs tree (removing the files in .cvsignore) +# Clean the cvs tree +# Removing the files in .cvsignore olddir=`pwd` for i in `find -name .cvsignore | sed s/.cvsignore//`; do cd $i rm -rf `cat .cvsignore` cd $olddir done + +# Removing the backup files +rm -f `find -name "*~"` +rm -f `find -name "#*#"` |
|
From: Xos? O. <xos...@us...> - 2004-03-16 04:01:45
|
Update of /cvsroot/dmn/dmn/doc In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv19520 Added Files: CodingStyle Log Message: A coding style is needed for any project because if every contributor add source with his/her personal style, when somebody reads the sources will have to switch between one style to other. --- NEW FILE: CodingStyle --- (This appears to be a binary file; contents omitted.) |
|
From: <xos...@us...> - 2004-01-15 03:27:08
|
Update of /cvsroot/dmn/web/htdocs In directory sc8-pr-cvs1:/tmp/cvs-serv14329 Modified Files: index.html index_ca.html index_es.html index_gl.html Log Message: There is not Documentation in sourceforge any more for dmn Index: index.html =================================================================== RCS file: /cvsroot/dmn/web/htdocs/index.html,v retrieving revision 1.14 retrieving revision 1.15 diff -u -d -r1.14 -r1.15 --- index.html 15 Jan 2004 03:24:09 -0000 1.14 +++ index.html 15 Jan 2004 03:27:00 -0000 1.15 @@ -56,8 +56,6 @@ <br /> <a href="http://sourceforge.net/projects/dmn">About the Project</a> <br /> - <a href="http://sourceforge.net/docman/?group_id=73628">DMN Documentation</a> - <br /> <a href="http://sourceforge.net/mail/?group_id=73628">DMN Mailing Lists</a> </p> <p> Index: index_ca.html =================================================================== RCS file: /cvsroot/dmn/web/htdocs/index_ca.html,v retrieving revision 1.7 retrieving revision 1.8 diff -u -d -r1.7 -r1.8 --- index_ca.html 15 Jan 2004 03:24:09 -0000 1.7 +++ index_ca.html 15 Jan 2004 03:27:00 -0000 1.8 @@ -56,8 +56,6 @@ <br /> <a href="http://sourceforge.net/projects/dmn">Sobre el nostre projecte</a> <br /> - <a href="http://sourceforge.net/docman/?group_id=73628">Documentació sobre DMN</a> - <br /> <a href="http://sourceforge.net/mail/?group_id=73628">Llestes de correu</a> </p> <p> Index: index_es.html =================================================================== RCS file: /cvsroot/dmn/web/htdocs/index_es.html,v retrieving revision 1.10 retrieving revision 1.11 diff -u -d -r1.10 -r1.11 --- index_es.html 15 Jan 2004 03:24:09 -0000 1.10 +++ index_es.html 15 Jan 2004 03:27:00 -0000 1.11 @@ -55,8 +55,6 @@ <br /> <a href="http://sourceforge.net/projects/dmn">Sobre nuestro proyecto DMN</a> <br /> - <a href="http://sourceforge.net/docman/?group_id=73628">Documentación sobre DMN</a> - <br /> <a href="http://sourceforge.net/mail/?group_id=73628">Listas de correo</a> </p> <p> Index: index_gl.html =================================================================== RCS file: /cvsroot/dmn/web/htdocs/index_gl.html,v retrieving revision 1.9 retrieving revision 1.10 diff -u -d -r1.9 -r1.10 --- index_gl.html 15 Jan 2004 03:24:53 -0000 1.9 +++ index_gl.html 15 Jan 2004 03:27:00 -0000 1.10 @@ -56,8 +56,6 @@ <br /> <a href="http://sourceforge.net/projects/dmn">Sobre o proxecto</a> <br /> - <a href="http://sourceforge.net/docman/?group_id=73628">Documentación de DMN</a> - <br /> <a href="http://sourceforge.net/mail/?group_id=73628">Listas de correo de DMN</a> </p> <p> |
|
From: <xos...@us...> - 2004-01-15 03:24:58
|
Update of /cvsroot/dmn/web/htdocs In directory sc8-pr-cvs1:/tmp/cvs-serv14019 Modified Files: index_gl.html Log Message: Fixed typo. Index: index_gl.html =================================================================== RCS file: /cvsroot/dmn/web/htdocs/index_gl.html,v retrieving revision 1.8 retrieving revision 1.9 diff -u -d -r1.8 -r1.9 --- index_gl.html 15 Jan 2004 03:24:09 -0000 1.8 +++ index_gl.html 15 Jan 2004 03:24:53 -0000 1.9 @@ -81,7 +81,7 @@ <p> <a name="contactus"><b><i>Contacta con nós</i>:</b></a> (<a href="#top">top</a>) <br /> -Por facor, emprega as <a href="http://sourceforge.net/mail/?group_id=73628">Listas de correo para te pór en contacto con nós. +Por favor, emprega as <a href="http://sourceforge.net/mail/?group_id=73628">Listas de correo para te pór en contacto con nós. </p> </td> </tr> |
|
From: <xos...@us...> - 2004-01-15 03:24:12
|
Update of /cvsroot/dmn/web/htdocs In directory sc8-pr-cvs1:/tmp/cvs-serv13834 Modified Files: index.html index_ca.html index_es.html index_gl.html Log Message: There is not "Forums" any more. Index: index.html =================================================================== RCS file: /cvsroot/dmn/web/htdocs/index.html,v retrieving revision 1.13 retrieving revision 1.14 diff -u -d -r1.13 -r1.14 --- index.html 27 Dec 2003 03:23:25 -0000 1.13 +++ index.html 15 Jan 2004 03:24:09 -0000 1.14 @@ -56,8 +56,6 @@ <br /> <a href="http://sourceforge.net/projects/dmn">About the Project</a> <br /> - <a href="http://sourceforge.net/forum/?group_id=73628">Public DMN Forums</a> - <br /> <a href="http://sourceforge.net/docman/?group_id=73628">DMN Documentation</a> <br /> <a href="http://sourceforge.net/mail/?group_id=73628">DMN Mailing Lists</a> @@ -83,9 +81,7 @@ <p> <a name="contactus"><b><i>Contact us</i>:</b></a> (<a href="#top">top</a>) <br /> -Please use the <a href="http://sourceforge.net/mail/?group_id=73628">Mailing Lists</a> or the -<a href="http://sourceforge.net/forum/?group_id=73628">Public Forum</a> at -<a href="http://sourceforge.net/projects/dmn">DMN-sf.net</a> to contact us. +Please use the <a href="http://sourceforge.net/mail/?group_id=73628">Mailing Lists to contact us. </p> </td> </tr> Index: index_ca.html =================================================================== RCS file: /cvsroot/dmn/web/htdocs/index_ca.html,v retrieving revision 1.6 retrieving revision 1.7 diff -u -d -r1.6 -r1.7 --- index_ca.html 27 Dec 2003 18:51:10 -0000 1.6 +++ index_ca.html 15 Jan 2004 03:24:09 -0000 1.7 @@ -56,8 +56,6 @@ <br /> <a href="http://sourceforge.net/projects/dmn">Sobre el nostre projecte</a> <br /> - <a href="http://sourceforge.net/forum/?group_id=73628">Fòrums Públics</a> - <br /> <a href="http://sourceforge.net/docman/?group_id=73628">Documentació sobre DMN</a> <br /> <a href="http://sourceforge.net/mail/?group_id=73628">Llestes de correu</a> @@ -83,9 +81,7 @@ <p> <a name="contactus"><b><i>Contacta amb nosaltres</i>:</b></a> (<a href="#top">top</a>) <br /> -Si vols posar-te en contacte amb nosaltres, per favor usa les <a href="http://sourceforge.net/mail/?group_id=73628">llistes de correu</a> o bé els distints -<a href="http://sourceforge.net/forum/?group_id=73628">fòrums</a> que trobaràs en -<a href="http://sourceforge.net/projects/dmn">DMN-sf.net</a>. +Si vols posar-te en contacte amb nosaltres, per favor usa les <a href="http://sourceforge.net/mail/?group_id=73628">llistes de correu</a>. </p> </td> </tr> Index: index_es.html =================================================================== RCS file: /cvsroot/dmn/web/htdocs/index_es.html,v retrieving revision 1.9 retrieving revision 1.10 diff -u -d -r1.9 -r1.10 --- index_es.html 27 Dec 2003 03:23:25 -0000 1.9 +++ index_es.html 15 Jan 2004 03:24:09 -0000 1.10 @@ -55,8 +55,6 @@ <br /> <a href="http://sourceforge.net/projects/dmn">Sobre nuestro proyecto DMN</a> <br /> - <a href="http://sourceforge.net/forum/?group_id=73628">Foros Públicos</a> - <br /> <a href="http://sourceforge.net/docman/?group_id=73628">Documentación sobre DMN</a> <br /> <a href="http://sourceforge.net/mail/?group_id=73628">Listas de correo</a> @@ -82,9 +80,7 @@ <p> <a name="contactus"><b><i>Contacta con nosotros</i>:</b></a> (<a href="#top">top</a>) <br /> -Si quieres ponerte en contacto con nosotros, por favor usa las <a href="http://sourceforge.net/mail/?group_id=73628">listas de correo</a> o bien los distintos -<a href="http://sourceforge.net/forum/?group_id=73628">foros</a> que encontrarás en -<a href="http://sourceforge.net/projects/dmn">DMN-sf.net</a> +Si quieres ponerte en contacto con nosotros, por favor usa las <a href="http://sourceforge.net/mail/?group_id=73628">listas de correo</a>. </p> </td> </tr> Index: index_gl.html =================================================================== RCS file: /cvsroot/dmn/web/htdocs/index_gl.html,v retrieving revision 1.7 retrieving revision 1.8 diff -u -d -r1.7 -r1.8 --- index_gl.html 27 Dec 2003 03:23:25 -0000 1.7 +++ index_gl.html 15 Jan 2004 03:24:09 -0000 1.8 @@ -56,8 +56,6 @@ <br /> <a href="http://sourceforge.net/projects/dmn">Sobre o proxecto</a> <br /> - <a href="http://sourceforge.net/forum/?group_id=73628">Foros públicos de DMN</a> - <br /> <a href="http://sourceforge.net/docman/?group_id=73628">Documentación de DMN</a> <br /> <a href="http://sourceforge.net/mail/?group_id=73628">Listas de correo de DMN</a> @@ -83,9 +81,7 @@ <p> <a name="contactus"><b><i>Contacta con nós</i>:</b></a> (<a href="#top">top</a>) <br /> -Por facor, emprega as <a href="http://sourceforge.net/mail/?group_id=73628">Listas de correo</a> ou os -<a href="http://sourceforge.net/forum/?group_id=73628">Foros Públicos</a> en -<a href="http://sourceforge.net/projects/dmn">DMN-sf.net</a> para te pór en contacto con nós. +Por facor, emprega as <a href="http://sourceforge.net/mail/?group_id=73628">Listas de correo para te pór en contacto con nós. </p> </td> </tr> |
|
From: <xos...@us...> - 2004-01-07 10:43:03
|
Update of /cvsroot/dmn/dmn/src
In directory sc8-pr-cvs1:/tmp/cvs-serv15723/src
Modified Files:
main.cpp
Log Message:
Deactive the signal catched during the signal handler execution
Index: main.cpp
===================================================================
RCS file: /cvsroot/dmn/dmn/src/main.cpp,v
retrieving revision 1.4
retrieving revision 1.5
diff -u -d -r1.4 -r1.5
--- main.cpp 7 Jan 2004 10:34:56 -0000 1.4
+++ main.cpp 7 Jan 2004 10:43:00 -0000 1.5
@@ -81,6 +81,9 @@
*/
void sighandler(int sig)
{
+ // Ignore a second signal
+ signal(sig, SIG_IGN);
+
switch(sig) {
case SIGSEGV:
Msg::error(-1, _("\
@@ -98,6 +101,10 @@
Msg::error(-1, _("Caught signal %d\n"), sig);
exit(-1);
}
+
+ // Restore the handler
+ // If some signal doesn't exit() from dmn the handler must be reassigned
+ // signal(sig, sighandler);
}
#endif
|
|
From: <xos...@us...> - 2004-01-07 10:43:03
|
Update of /cvsroot/dmn/dmn In directory sc8-pr-cvs1:/tmp/cvs-serv15723 Modified Files: ChangeLog Log Message: Deactive the signal catched during the signal handler execution Index: ChangeLog =================================================================== RCS file: /cvsroot/dmn/dmn/ChangeLog,v retrieving revision 1.39 retrieving revision 1.40 diff -u -d -r1.39 -r1.40 --- ChangeLog 7 Jan 2004 10:34:56 -0000 1.39 +++ ChangeLog 7 Jan 2004 10:43:00 -0000 1.40 @@ -1,5 +1,10 @@ 2004-01-07 Xosé Otero <x_...@te...> + * src/main.cpp: Deactive the signal catched during the signal handler + execution + +2004-01-07 Xosé Otero <x_...@te...> + * src/main.cpp: It was a bad idea to ignore SIGINT and SIGQUIT, i want to quit dmn with ^C |
|
From: <xos...@us...> - 2004-01-07 10:34:59
|
Update of /cvsroot/dmn/dmn In directory sc8-pr-cvs1:/tmp/cvs-serv14437 Modified Files: ChangeLog Log Message: It was a bad idea to ignore SIGINT and SIGQUIT, i want to quit dmn with ^C Index: ChangeLog =================================================================== RCS file: /cvsroot/dmn/dmn/ChangeLog,v retrieving revision 1.38 retrieving revision 1.39 diff -u -d -r1.38 -r1.39 --- ChangeLog 6 Jan 2004 11:28:19 -0000 1.38 +++ ChangeLog 7 Jan 2004 10:34:56 -0000 1.39 @@ -1,3 +1,8 @@ +2004-01-07 Xosé Otero <x_...@te...> + + * src/main.cpp: It was a bad idea to ignore SIGINT and SIGQUIT, i want + to quit dmn with ^C + 2004-01-06 Xosé Otero <x_...@te...> * src/main.cpp: Added signal management (ignore SIGINT, SIGQUIT and |
|
From: <xos...@us...> - 2004-01-07 10:34:59
|
Update of /cvsroot/dmn/dmn/src In directory sc8-pr-cvs1:/tmp/cvs-serv14437/src Modified Files: main.cpp Log Message: It was a bad idea to ignore SIGINT and SIGQUIT, i want to quit dmn with ^C Index: main.cpp =================================================================== RCS file: /cvsroot/dmn/dmn/src/main.cpp,v retrieving revision 1.3 retrieving revision 1.4 diff -u -d -r1.3 -r1.4 --- main.cpp 6 Jan 2004 11:28:19 -0000 1.3 +++ main.cpp 7 Jan 2004 10:34:56 -0000 1.4 @@ -121,9 +121,6 @@ #if HAVE_SIGNAL_H /* Set signals handlers */ - /* Signals to ignore */ - signal(SIGINT, SIG_IGN); - signal(SIGQUIT, SIG_IGN); /* Signals to catch */ signal(SIGHUP, sighandler); signal(SIGILL, sighandler); |
|
From: <xos...@us...> - 2004-01-06 11:28:22
|
Update of /cvsroot/dmn/dmn/src
In directory sc8-pr-cvs1:/tmp/cvs-serv353/src
Modified Files:
main.cpp
Log Message:
Added signal management (ignore SIGINT, SIGQUIT and catch SIGHUP, SIGILL,
SIGBUS, SIGSEGV showing a error message)
Index: main.cpp
===================================================================
RCS file: /cvsroot/dmn/dmn/src/main.cpp,v
retrieving revision 1.2
retrieving revision 1.3
diff -u -d -r1.2 -r1.3
--- main.cpp 29 Dec 2003 04:31:51 -0000 1.2
+++ main.cpp 6 Jan 2004 11:28:19 -0000 1.3
@@ -27,19 +27,22 @@
#include <dmn/config.h>
#include <dmn/msg.h>
-#include <stdlib.h>
+#include <cstdlib>
#ifdef ENABLE_NLS
#include <locale.h>
#endif
+#if HAVE_SIGNAL_H
+#include <signal.h>
+#endif
+
+using namespace dmn;
+using namespace std;
/* Which is the default Config module? For example: "default" */
#ifndef DEFAULT_CONFIG
#error DEFAULT_CONFIG must be defined!
#endif
-using namespace dmn;
-using namespace std;
-
/**
* Open/close Config module
*/
@@ -70,6 +73,34 @@
*/
bool play_dmn();
+#if HAVE_SIGNAL_H
+/**
+ * Signal handler
+ *
+ * @params sig signal catched
+ */
+void sighandler(int sig)
+{
+ switch(sig) {
+ case SIGSEGV:
+ Msg::error(-1, _("\
+DMN has segfaulted and attempted to dump a core file.\n\
+This is a bug in the software and has happened through\n\
+no fault of your own.\n\n\
+It is possible that this bug is already fixed in CVS.\n\
+If you can reproduce the crash, please notify the DMN\n\
+maintainers by sending a mail to <%s>.\n\n\
+Please make sure to specify what you were doing at the time,\n\
+and post the backtrace from the core file.\n\
+"), PROGRAM_EMAIL.c_str());
+ abort();
+ default:
+ Msg::error(-1, _("Caught signal %d\n"), sig);
+ exit(-1);
+ }
+}
+#endif
+
/**
* Main DMN function
*
@@ -86,6 +117,18 @@
bindtextdomain(PACKAGE, LOCALEDIR);
bind_textdomain_codeset(PACKAGE, "UTF-8");
textdomain(PACKAGE);
+#endif
+
+#if HAVE_SIGNAL_H
+ /* Set signals handlers */
+ /* Signals to ignore */
+ signal(SIGINT, SIG_IGN);
+ signal(SIGQUIT, SIG_IGN);
+ /* Signals to catch */
+ signal(SIGHUP, sighandler);
+ signal(SIGILL, sighandler);
+ signal(SIGBUS, sighandler);
+ signal(SIGSEGV, sighandler);
#endif
/* Setup */
|
|
From: <xos...@us...> - 2004-01-06 11:28:22
|
Update of /cvsroot/dmn/dmn In directory sc8-pr-cvs1:/tmp/cvs-serv353 Modified Files: configure.in ChangeLog Log Message: Added signal management (ignore SIGINT, SIGQUIT and catch SIGHUP, SIGILL, SIGBUS, SIGSEGV showing a error message) Index: configure.in =================================================================== RCS file: /cvsroot/dmn/dmn/configure.in,v retrieving revision 1.24 retrieving revision 1.25 diff -u -d -r1.24 -r1.25 --- configure.in 4 Jan 2004 04:19:14 -0000 1.24 +++ configure.in 6 Jan 2004 11:28:19 -0000 1.25 @@ -44,7 +44,7 @@ dnl Checks for header files. AC_HEADER_DIRENT AC_HEADER_STDC -AC_CHECK_HEADERS(string.h) +AC_CHECK_HEADERS(string.h signal.h) dnl AC_CHECK_HEADERS([argz.h arpa/inet.h fcntl.h inttypes.h langinfo.h libintl.h limits.h locale.h malloc.h memory.h netinet/in.h stddef.h stdint.h stdio_ext.h stdlib.h string.h strings.h sys/param.h sys/socket.h sys/time.h unistd.h]) dnl Checks for typedefs, structures, and compiler characteristics. Index: ChangeLog =================================================================== RCS file: /cvsroot/dmn/dmn/ChangeLog,v retrieving revision 1.37 retrieving revision 1.38 diff -u -d -r1.37 -r1.38 --- ChangeLog 31 Dec 2003 22:51:43 -0000 1.37 +++ ChangeLog 6 Jan 2004 11:28:19 -0000 1.38 @@ -1,3 +1,8 @@ +2004-01-06 Xosé Otero <x_...@te...> + + * src/main.cpp: Added signal management (ignore SIGINT, SIGQUIT and + catch SIGHUP, SIGILL, SIGBUS, SIGSEGV showing a error message) + 2003-12-31 Xosé Otero <x_...@te...> * src/Hand/default.cpp: Fixed bug 837465 |
|
From: <xos...@us...> - 2004-01-04 04:19:19
|
Update of /cvsroot/dmn/dmn In directory sc8-pr-cvs1:/tmp/cvs-serv19046 Modified Files: configure.in Log Message: If libltdl is not found, don't install it, add it to dmn as a static library instead. Index: configure.in =================================================================== RCS file: /cvsroot/dmn/dmn/configure.in,v retrieving revision 1.23 retrieving revision 1.24 diff -u -d -r1.23 -r1.24 --- configure.in 29 Dec 2003 09:49:52 -0000 1.23 +++ configure.in 4 Jan 2004 04:19:14 -0000 1.24 @@ -28,8 +28,7 @@ AC_PROG_LN_S AC_PROG_MAKE_SET AC_LIBTOOL_DLOPEN -dnl AC_LIBLTDL_CONVENIENCE -AC_LIBLTDL_INSTALLABLE +AC_LIBLTDL_CONVENIENCE AC_PROG_LIBTOOL AC_PROG_YACC dnl AC_ENABLE_SHARED(yes) |
|
From: <xos...@us...> - 2003-12-31 22:51:47
|
Update of /cvsroot/dmn/dmn In directory sc8-pr-cvs1:/tmp/cvs-serv14797 Modified Files: ChangeLog Log Message: Fixed bug 837465 (Dooonng, Dooong... -cuidao con los cuartos-) Index: ChangeLog =================================================================== RCS file: /cvsroot/dmn/dmn/ChangeLog,v retrieving revision 1.36 retrieving revision 1.37 diff -u -d -r1.36 -r1.37 --- ChangeLog 30 Dec 2003 09:14:16 -0000 1.36 +++ ChangeLog 31 Dec 2003 22:51:43 -0000 1.37 @@ -1,3 +1,7 @@ +2003-12-31 Xosé Otero <x_...@te...> + + * src/Hand/default.cpp: Fixed bug 837465 + 2003-12-30 Xosé Otero <x_...@te...> * src/Player/text.cpp: Xosé using a scanf with a HalfDomino? ;) |
|
From: <xos...@us...> - 2003-12-31 22:51:47
|
Update of /cvsroot/dmn/dmn/src/Hand
In directory sc8-pr-cvs1:/tmp/cvs-serv14797/src/Hand
Modified Files:
default.cpp
Log Message:
Fixed bug 837465 (Dooonng, Dooong... -cuidao con los cuartos-)
Index: default.cpp
===================================================================
RCS file: /cvsroot/dmn/dmn/src/Hand/default.cpp,v
retrieving revision 1.2
retrieving revision 1.3
diff -u -d -r1.2 -r1.3
--- default.cpp 30 Dec 2003 09:10:41 -0000 1.2
+++ default.cpp 31 Dec 2003 22:51:44 -0000 1.3
@@ -556,7 +556,8 @@
if (player_can_play(player, aux->dominoes))
return false;
- if (dominoes_.size() == 0 || turn_ != player) {
+ if (dominoes_.size() == 0 || turn_ != player ||
+ dominoes_played_.size() == 0) {
/* Calculate the next turn */
turn_ = next_turn();
return false;
|