MCPcopy Create free account
hub / github.com/OpenDungeons/OpenDungeons / exportSeatToStream

Method exportSeatToStream

source/game/Seat.cpp:1122–1263  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

1120
1121
1122bool Seat::exportSeatToStream(std::ostream& os) const
1123{
1124 os << "seatId\t";
1125 os << mId;
1126 os << std::endl;
1127 // If the team id is set, we save it. Otherwise, we save all the available team ids
1128 // That way, save map will work in both editor and in game.
1129 os << "teamId\t";
1130 if(mTeamId != -1)
1131 {
1132 os << mTeamId;
1133 }
1134 else
1135 {
1136 int cpt = 0;
1137 for(int teamId : mAvailableTeamIds)
1138 {
1139 if(cpt > 0)
1140 os << "/";
1141
1142 os << teamId;
1143 ++cpt;
1144 }
1145 }
1146 os << std::endl;
1147
1148 // On editor, we write the original player type. If we are saving a game, we keep the assigned type
1149 if((mGameMap->isInEditorMode()) ||
1150 (getPlayer() == nullptr))
1151 {
1152 os << "player\t";
1153 os << mPlayerType;
1154 os << std::endl;
1155 }
1156 else
1157 {
1158 os << "player\t";
1159 if(getPlayer()->getIsHuman())
1160 os << PLAYER_TYPE_HUMAN;
1161 else
1162 os << PLAYER_TYPE_AI;
1163
1164 os << std::endl;
1165 }
1166
1167 os << "faction\t";
1168 os << mFaction;
1169 os << std::endl;
1170
1171 os << "startingX\t";
1172 os << mStartingX;
1173 os << std::endl;
1174
1175 os << "startingY\t";
1176 os << mStartingY;
1177 os << std::endl;
1178
1179 os << "colorId\t";

Callers 1

writeGameMapToFileFunction · 0.80

Calls 3

isInEditorModeMethod · 0.80
getIsHumanMethod · 0.80
toStringFunction · 0.70

Tested by

no test coverage detected