MCPcopy Create free account
hub / github.com/BohemiaInteractive/CWR / ApplyVoting

Method ApplyVoting

engine/Poseidon/Network/NetworkServer.cpp:723–854  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

721
722 // add mission directories
723 const std::string dirMask = (std::filesystem::path(dir) / "*.*").string();
724 h = _findfirst(dirMask.c_str(), &info);
725 if (h != -1)
726 {
727 do
728 {
729 if ((info.attrib & _A_SUBDIR) != 0 && info.name[0] != '.')
730 {
731 addMission(info.name, (std::filesystem::path(dir) / info.name).string(), "directory");
732 }
733 } while (_findnext(h, &info) == 0);
734 _findclose(h);
735 }
736 }
737 LOG_DEBUG(Network, "MP mission scan complete: {} templates", added.size());
738 answer.content.WriteString("");
739}
740
741void NetworkServer::ApplyVoting(const AutoArray<char>& id, const AutoArray<char>* value)
742{
743 int* ptr = (int*)id.Data();
744 int type = *(ptr++);
745 switch (type)
746 {
747 case NCMTMission:
748 if (value)
749 {
750 const char* p = value->Data();
751 _mission = p;
752 p += strlen(p) + 1;
753 _cadetMode = *(bool*)p;
754 if (_mission.GetLength() > 0)
755 {
756 _restart = true;
757 }
758 if (_state != NGSPlay)
759 {
760 GNetworkManager.DestroyAllObjects();
761 SetGameState(NGSCreate);
762 }
763 }
764 break;
765 case NCMTMissions:
766 {
767 _mission = "?";
768 _restart = true;
769 if (_state != NGSPlay)
770 {
771 GNetworkManager.DestroyAllObjects();
772 SetGameState(NGSCreate);
773 }
774 NetworkCommandMessage answer;
775 answer.type = NCMTVoteMission;
776 AddMissionList(answer);
777 for (int i = 0; i < _identities.Size(); i++)
778 {
779 SendMsg(_identities[i].dpnid, &answer, NMFGuaranteed);
780 }

Callers 2

AddMethod · 0.80
CheckMethod · 0.80

Calls 7

AddMissionListFunction · 0.85
DataMethod · 0.45
GetLengthMethod · 0.45
DestroyAllObjectsMethod · 0.45
SizeMethod · 0.45
ClearMethod · 0.45
WriteMethod · 0.45

Tested by

no test coverage detected