// receive a template created by another player bool recvTemplate(NETQUEUE queue) { uint32_t player; DROID_TEMPLATE *psTempl; DROID_TEMPLATE t; NETbeginDecode(queue, GAME_TEMPLATE); NETuint32_t(&player); ASSERT_OR_RETURN(false, player < MAX_PLAYERS, "invalid player size: %d", player); NETtemplate(&t); NETend(); if (!canGiveOrdersFor(queue.index, player)) { return false; } t.prefab = false; t.psNext = NULL; t.pName = NULL; t.ref = REF_TEMPLATE_START; psTempl = IdToTemplate(t.multiPlayerID,player); // Already exists if (psTempl) { t.psNext = psTempl->psNext; *psTempl = t; debug(LOG_SYNC, "Updating MP template %d (stored=%s)", (int)t.multiPlayerID, t.stored ? "yes" : "no"); } else { addTemplateBack(player, &t); // Add to back of list, to avoid game state templates being in wrong order, which matters when saving games. debug(LOG_SYNC, "Creating MP template %d (stored=%s)", (int)t.multiPlayerID, t.stored ? "yes" : "no"); } if (!t.prefab && player == selectedPlayer) { storeTemplates(); } return true; }
bool shutdownTemplates() { return storeTemplates(); }