[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Eliot-dev] Changes to eliot/game/game_io.cpp [antoine-1]
From: |
eliot-dev |
Subject: |
[Eliot-dev] Changes to eliot/game/game_io.cpp [antoine-1] |
Date: |
Sun, 23 Oct 2005 16:58:59 -0400 |
Index: eliot/game/game_io.cpp
diff -u eliot/game/game_io.cpp:1.1.2.2 eliot/game/game_io.cpp:1.1.2.3
--- eliot/game/game_io.cpp:1.1.2.2 Sun Oct 23 19:12:14 2005
+++ eliot/game/game_io.cpp Sun Oct 23 20:58:20 2005
@@ -18,8 +18,6 @@
* Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
*****************************************************************************/
-/* $Id: game_io.cpp,v 1.1.2.2 2005/10/23 19:12:14 ipkiss Exp $ */
-
/**
* \file game_io.cpp
* \brief Eliot game class file load/save handling
@@ -95,56 +93,56 @@
pGame->start();
while(fgets(buff,sizeof(buff),fin))
- {
+ {
token = strtok(buff,delim);
if (token != NULL)
- {
+ {
if (strcmp(token,"total")==0)
- {
+ {
break;
- }
+ }
/* rack */
- strncpy(rack,token,sizeof(rack));
-
((Training*)pGame)->setRack(PlayedRack::RACK_MANUAL,false,std::string(rack));
+ strncpy(rack,token,sizeof(rack));
+
((Training*)pGame)->setRack(PlayedRack::RACK_MANUAL,false,std::string(rack));
/* word */
- token = strtok(NULL,delim);
- if (!token || strcmp(token,"total")==0)
- {
- //std::cerr << "break2" << endl;
- break;
- }
-
- strncpy(word,token,sizeof(word));
- //std::cerr << "\t" << word << " ";
- /* bonus */
- if ((token = strtok(NULL,delim)) == NULL)
- break;
- /* points */
- if (token[0]=='*')
- {
- //std::cerr << token << " \t";
- if ((token = strtok(NULL,delim)) == NULL)
- break;
- }
-
- /* pos 1 */
- if ((token = strtok(NULL,delim)) == NULL)
- break;
- //std::cerr << "(" << token << " ";
- strncpy(pos,token,sizeof(pos));
-
- /* pos 2 */
- if ((token = strtok(NULL,delim)) == NULL)
- break;
- //std::cerr << token << ")";
- strncat(pos,token,sizeof(pos));
- //std::cerr << pos << endl;
-
- pGame->play(0,std::string(pos),std::string(word));
- }
- }
+ token = strtok(NULL,delim);
+ if (!token || strcmp(token,"total")==0)
+ {
+ //std::cerr << "break2" << endl;
+ break;
+ }
+
+ strncpy(word,token,sizeof(word));
+ //std::cerr << "\t" << word << " ";
+ /* bonus */
+ if ((token = strtok(NULL,delim)) == NULL)
+ break;
+ /* points */
+ if (token[0]=='*')
+ {
+ //std::cerr << token << " \t";
+ if ((token = strtok(NULL,delim)) == NULL)
+ break;
+ }
+
+ /* pos 1 */
+ if ((token = strtok(NULL,delim)) == NULL)
+ break;
+ //std::cerr << "(" << token << " ";
+ strncpy(pos,token,sizeof(pos));
+
+ /* pos 2 */
+ if ((token = strtok(NULL,delim)) == NULL)
+ break;
+ //std::cerr << token << ")";
+ strncat(pos,token,sizeof(pos));
+ //std::cerr << pos << endl;
+
+ pGame->play(0,std::string(pos),std::string(word));
+ }
+ }
return pGame;
}
@@ -196,15 +194,15 @@
char type[20];
if (sscanf(pos, "Player %d: %19s", &nb, type) > 1)
{
- if (pGame->getMode() != kTRAINING)
- {
- if (std::string(type) == "Human")
- pGame->addHumanPlayer();
- else if (std::string(type) == "Computer")
- pGame->addAIPlayer();
- else
- ;
- }
+ if (pGame->getMode() != kTRAINING)
+ {
+ if (std::string(type) == "Human")
+ pGame->addHumanPlayer();
+ else if (std::string(type) == "Computer")
+ pGame->addAIPlayer();
+ else
+ ;
+ }
}
// Read next line
continue;
@@ -317,7 +315,7 @@
else
{
// Vertical word
- round.setDir(VERTICAL);
+ round.setDir(Coord::VERTICAL);
round.setRow(ref[strlen(ref) - 1] - 'A' + 1);
round.setCol(atoi(ref));
@@ -390,7 +388,7 @@
char buff[100];
const char decal[]=" ";
out << IDENT_STRING << std::endl << std::endl;
- for(i = 0; i < m_history.getSize(); i++)
+ for(i = 0; i < m_history.getSize(); i++)
{
Turn t = m_history.getTurn(i);
out << decal << t.toString() << std::endl;
@@ -432,13 +430,13 @@
std::string word = getPlayedWord(i);
std::string coord = getPlayedCoords(i);
sprintf(line, "%2d | %8s | %s%s | %3s | %3d | %1d | %c",
- i + 1,
+ i + 1,
getPlayedRack(i).c_str(), /* pldrack */
word.c_str(), /* word */
std::string(15 - word.size(), ' ').c_str(), /* fill spaces */
coord.c_str(), /* coord */
getPlayedPoints(i),
- getPlayedPlayer(i),
+ getPlayedPlayer(i),
getPlayedBonus(i) ? '*' : ' ');
out << decal << line << std::endl;