* @brief Called by engine for single, called by ui for multi */
| 153 | * @brief Called by engine for single, called by ui for multi |
| 154 | */ |
| 155 | bool SNetCreateGame(const char *pszGameName, const char *pszGamePassword, char *gameTemplateData, int gameTemplateSize, int *playerID) |
| 156 | { |
| 157 | #ifndef NONET |
| 158 | std::lock_guard<SdlMutex> lg(storm_net_mutex); |
| 159 | #endif |
| 160 | if (gameTemplateSize != sizeof(GameData)) |
| 161 | ABORT(); |
| 162 | net::buffer_t gameInitInfo(gameTemplateData, gameTemplateData + gameTemplateSize); |
| 163 | dvlnet_inst->setup_gameinfo(std::move(gameInitInfo)); |
| 164 | |
| 165 | std::string defaultName; |
| 166 | if (pszGameName == nullptr) { |
| 167 | defaultName = dvlnet_inst->make_default_gamename(); |
| 168 | pszGameName = defaultName.c_str(); |
| 169 | } |
| 170 | |
| 171 | GameName = pszGameName; |
| 172 | if (pszGamePassword != nullptr) |
| 173 | DvlNet_SetPassword(pszGamePassword); |
| 174 | else |
| 175 | DvlNet_ClearPassword(); |
| 176 | *playerID = dvlnet_inst->create(pszGameName); |
| 177 | return *playerID != -1; |
| 178 | } |
| 179 | |
| 180 | bool SNetJoinGame(char *pszGameName, char *pszGamePassword, int *playerID) |
| 181 | { |
no test coverage detected