void CPlayer::Snap(int SnappingClient) { if(!IsDummy() && !Server()->ClientIngame(m_ClientID)) return; CNetObj_PlayerInfo *pPlayerInfo = static_cast<CNetObj_PlayerInfo *>(Server()->SnapNewItem(NETOBJTYPE_PLAYERINFO, m_ClientID, sizeof(CNetObj_PlayerInfo))); if(!pPlayerInfo) return; pPlayerInfo->m_PlayerFlags = m_PlayerFlags&PLAYERFLAG_CHATTING; if(Server()->IsAuthed(m_ClientID)) pPlayerInfo->m_PlayerFlags |= PLAYERFLAG_ADMIN; if(!GameServer()->m_pController->IsPlayerReadyMode() || m_IsReadyToPlay) pPlayerInfo->m_PlayerFlags |= PLAYERFLAG_READY; if(m_RespawnDisabled && (!GetCharacter() || !GetCharacter()->IsAlive())) pPlayerInfo->m_PlayerFlags |= PLAYERFLAG_DEAD; if(SnappingClient != -1 && (m_Team == TEAM_SPECTATORS || m_DeadSpecMode) && SnappingClient == m_SpectatorID) pPlayerInfo->m_PlayerFlags |= PLAYERFLAG_WATCHING; pPlayerInfo->m_Latency = SnappingClient == -1 ? m_Latency.m_Min : GameServer()->m_apPlayers[SnappingClient]->m_aActLatency[m_ClientID]; pPlayerInfo->m_Score = m_Score; if(m_ClientID == SnappingClient && (m_Team == TEAM_SPECTATORS || m_DeadSpecMode)) { CNetObj_SpectatorInfo *pSpectatorInfo = static_cast<CNetObj_SpectatorInfo *>(Server()->SnapNewItem(NETOBJTYPE_SPECTATORINFO, m_ClientID, sizeof(CNetObj_SpectatorInfo))); if(!pSpectatorInfo) return; pSpectatorInfo->m_SpectatorID = m_SpectatorID; pSpectatorInfo->m_X = m_ViewPos.x; pSpectatorInfo->m_Y = m_ViewPos.y; } // demo recording if(SnappingClient == -1) { CNetObj_De_ClientInfo *pClientInfo = static_cast<CNetObj_De_ClientInfo *>(Server()->SnapNewItem(NETOBJTYPE_DE_CLIENTINFO, m_ClientID, sizeof(CNetObj_De_ClientInfo))); if(!pClientInfo) return; pClientInfo->m_Local = 0; pClientInfo->m_Team = m_Team; StrToInts(pClientInfo->m_aName, 4, Server()->ClientName(m_ClientID)); StrToInts(pClientInfo->m_aClan, 3, Server()->ClientClan(m_ClientID)); pClientInfo->m_Country = Server()->ClientCountry(m_ClientID); for(int p = 0; p < 6; p++) { StrToInts(pClientInfo->m_aaSkinPartNames[p], 6, m_TeeInfos.m_aaSkinPartNames[p]); pClientInfo->m_aUseCustomColors[p] = m_TeeInfos.m_aUseCustomColors[p]; pClientInfo->m_aSkinPartColors[p] = m_TeeInfos.m_aSkinPartColors[p]; } } }
void CPlayer::Snap(int SnappingClient) { #ifdef CONF_DEBUG if(!g_Config.m_DbgDummies || m_ClientID < MAX_CLIENTS-g_Config.m_DbgDummies) #endif if(!Server()->ClientIngame(m_ClientID)) return; CNetObj_ClientInfo *pClientInfo = static_cast<CNetObj_ClientInfo *>(Server()->SnapNewItem(NETOBJTYPE_CLIENTINFO, m_ClientID, sizeof(CNetObj_ClientInfo))); if(!pClientInfo) return; StrToInts(&pClientInfo->m_Name0, 4, Server()->ClientName(m_ClientID)); StrToInts(&pClientInfo->m_Clan0, 3, Server()->ClientClan(m_ClientID)); pClientInfo->m_Country = Server()->ClientCountry(m_ClientID); StrToInts(&pClientInfo->m_Skin0, 6, m_TeeInfos.m_SkinName); pClientInfo->m_UseCustomColor = m_TeeInfos.m_UseCustomColor; pClientInfo->m_ColorBody = m_TeeInfos.m_ColorBody; pClientInfo->m_ColorFeet = m_TeeInfos.m_ColorFeet; CNetObj_PlayerInfo *pPlayerInfo = static_cast<CNetObj_PlayerInfo *>(Server()->SnapNewItem(NETOBJTYPE_PLAYERINFO, m_ClientID, sizeof(CNetObj_PlayerInfo))); if(!pPlayerInfo) return; pPlayerInfo->m_Latency = SnappingClient == -1 ? m_Latency.m_Min : GameServer()->m_apPlayers[SnappingClient]->m_aActLatency[m_ClientID]; pPlayerInfo->m_Local = 0; pPlayerInfo->m_ClientID = m_ClientID; pPlayerInfo->m_Score = abs(m_Score) * -1; pPlayerInfo->m_Team = m_Team; if(m_ClientID == SnappingClient) pPlayerInfo->m_Local = 1; if(m_ClientID == SnappingClient && m_Team == TEAM_SPECTATORS) { CNetObj_SpectatorInfo *pSpectatorInfo = static_cast<CNetObj_SpectatorInfo *>(Server()->SnapNewItem(NETOBJTYPE_SPECTATORINFO, m_ClientID, sizeof(CNetObj_SpectatorInfo))); if(!pSpectatorInfo) return; pSpectatorInfo->m_SpectatorID = m_SpectatorID; pSpectatorInfo->m_X = m_ViewPos.x; pSpectatorInfo->m_Y = m_ViewPos.y; } // send 0 if times of others are not shown if(SnappingClient != m_ClientID && g_Config.m_SvHideScore) pPlayerInfo->m_Score = -9999; else pPlayerInfo->m_Score = abs(m_Score) * -1; pPlayerInfo->m_Team = m_Team; }
void CGameClient::OnDemoRecSnap() { // add client info for(int i = 0; i < MAX_CLIENTS; ++i) { if(!m_aClients[i].m_Active) continue; CNetObj_De_ClientInfo *pClientInfo = static_cast<CNetObj_De_ClientInfo *>(Client()->SnapNewItem(NETOBJTYPE_DE_CLIENTINFO, i, sizeof(CNetObj_De_ClientInfo))); if(!pClientInfo) return; pClientInfo->m_Local = i==m_LocalClientID ? 1 : 0; pClientInfo->m_Team = m_aClients[i].m_Team; StrToInts(pClientInfo->m_aName, 4, m_aClients[i].m_aName); StrToInts(pClientInfo->m_aClan, 3, m_aClients[i].m_aClan); pClientInfo->m_Country = m_aClients[i].m_Country; for(int p = 0; p < 6; p++) { StrToInts(pClientInfo->m_aaSkinPartNames[p], 6, m_aClients[i].m_aaSkinPartNames[p]); pClientInfo->m_aUseCustomColors[p] = m_aClients[i].m_aUseCustomColors[p]; pClientInfo->m_aSkinPartColors[p] = m_aClients[i].m_aSkinPartColors[p]; } } // add tuning CTuningParams StandardTuning; if(mem_comp(&StandardTuning, &m_Tuning, sizeof(CTuningParams)) != 0) { CNetObj_De_TuneParams *pTuneParams = static_cast<CNetObj_De_TuneParams *>(Client()->SnapNewItem(NETOBJTYPE_DE_TUNEPARAMS, 0, sizeof(CNetObj_De_TuneParams))); if(!pTuneParams) return; mem_copy(pTuneParams->m_aTuneParams, &m_Tuning, sizeof(pTuneParams->m_aTuneParams)); } // add game info CNetObj_De_GameInfo *pGameInfo = static_cast<CNetObj_De_GameInfo *>(Client()->SnapNewItem(NETOBJTYPE_DE_GAMEINFO, 0, sizeof(CNetObj_De_GameInfo))); if(!pGameInfo) return; pGameInfo->m_GameFlags = m_GameInfo.m_GameFlags; pGameInfo->m_ScoreLimit = m_GameInfo.m_ScoreLimit; pGameInfo->m_TimeLimit = m_GameInfo.m_TimeLimit; pGameInfo->m_MatchNum = m_GameInfo.m_MatchNum; pGameInfo->m_MatchCurrent = m_GameInfo.m_MatchCurrent; }
void CGhost::GetGhostSkin(CGhostSkin *pSkin, const char *pSkinName, int UseCustomColor, int ColorBody, int ColorFeet) { StrToInts(&pSkin->m_Skin0, 6, pSkinName); pSkin->m_UseCustomColor = UseCustomColor; pSkin->m_ColorBody = ColorBody; pSkin->m_ColorFeet = ColorFeet; }
void CPlayer::Snap(int SnappingClient) { #ifdef CONF_DEBUG if(!g_Config.m_DbgDummies || m_ClientID < MAX_CLIENTS-g_Config.m_DbgDummies) #endif if(!Server()->ClientIngame(m_ClientID)) return; CNetObj_ClientInfo *pClientInfo = static_cast<CNetObj_ClientInfo *>(Server()->SnapNewItem(NETOBJTYPE_CLIENTINFO, m_ClientID, sizeof(CNetObj_ClientInfo))); if(!pClientInfo) return; StrToInts(&pClientInfo->m_Name0, 4, Server()->ClientName(m_ClientID)); StrToInts(&pClientInfo->m_Clan0, 3, Server()->ClientClan(m_ClientID)); pClientInfo->m_Country = Server()->ClientCountry(m_ClientID); StrToInts(&pClientInfo->m_Skin0, 6, m_TeeInfos.m_SkinName); pClientInfo->m_UseCustomColor = true; int KnockbackStrength = m_pCharacter ? m_pCharacter->m_KnockbackStrength : 0; int SkinHue = min(64 + KnockbackStrength * 10, 255) << 16; pClientInfo->m_ColorBody = SkinHue | 255 << 8; pClientInfo->m_ColorFeet = SkinHue | 127 << 8; CNetObj_PlayerInfo *pPlayerInfo = static_cast<CNetObj_PlayerInfo *>(Server()->SnapNewItem(NETOBJTYPE_PLAYERINFO, m_ClientID, sizeof(CNetObj_PlayerInfo))); if(!pPlayerInfo) return; pPlayerInfo->m_Latency = SnappingClient == -1 ? m_Latency.m_Min : GameServer()->m_apPlayers[SnappingClient]->m_aActLatency[m_ClientID]; pPlayerInfo->m_Local = 0; pPlayerInfo->m_ClientID = m_ClientID; pPlayerInfo->m_Score = m_Score; pPlayerInfo->m_Team = m_Team; if(m_ClientID == SnappingClient) pPlayerInfo->m_Local = 1; if(m_ClientID == SnappingClient && m_Team == TEAM_SPECTATORS) { CNetObj_SpectatorInfo *pSpectatorInfo = static_cast<CNetObj_SpectatorInfo *>(Server()->SnapNewItem(NETOBJTYPE_SPECTATORINFO, m_ClientID, sizeof(CNetObj_SpectatorInfo))); if(!pSpectatorInfo) return; pSpectatorInfo->m_SpectatorID = m_SpectatorID; pSpectatorInfo->m_X = m_ViewPos.x; pSpectatorInfo->m_Y = m_ViewPos.y; } }
void CPlayer::FakeSnap(int SnappingClient) { // This is problematic when it's sent before we know whether it's a non-64-player-client // Then we can't spectate players at the start IServer::CClientInfo info; Server()->GetClientInfo(SnappingClient, &info); CGameContext *GameContext = (CGameContext *) GameServer(); if (SnappingClient > -1 && GameContext->m_apPlayers[SnappingClient] && GameContext->m_apPlayers[SnappingClient]->m_ClientVersion >= VERSION_DDNET_OLD) return; int id = VANILLA_MAX_CLIENTS - 1; CNetObj_ClientInfo *pClientInfo = static_cast<CNetObj_ClientInfo *>(Server()->SnapNewItem(NETOBJTYPE_CLIENTINFO, id, sizeof(CNetObj_ClientInfo))); if(!pClientInfo) return; StrToInts(&pClientInfo->m_Name0, 4, " "); StrToInts(&pClientInfo->m_Clan0, 3, Server()->ClientClan(m_ClientID)); StrToInts(&pClientInfo->m_Skin0, 6, m_TeeInfos.m_SkinName); }
void CPlayer::FakeSnap() { // This is problematic when it's sent before we know whether it's a non-64-player-client // Then we can't spectate players at the start if(m_ClientVersion >= VERSION_DDNET_OLD) return; int FakeID = VANILLA_MAX_CLIENTS - 1; CNetObj_ClientInfo *pClientInfo = static_cast<CNetObj_ClientInfo *>(Server()->SnapNewItem(NETOBJTYPE_CLIENTINFO, FakeID, sizeof(CNetObj_ClientInfo))); if(!pClientInfo) return; StrToInts(&pClientInfo->m_Name0, 4, " "); StrToInts(&pClientInfo->m_Clan0, 3, ""); StrToInts(&pClientInfo->m_Skin0, 6, "default"); if(m_Paused != PAUSED_SPEC) return; CNetObj_PlayerInfo *pPlayerInfo = static_cast<CNetObj_PlayerInfo *>(Server()->SnapNewItem(NETOBJTYPE_PLAYERINFO, FakeID, sizeof(CNetObj_PlayerInfo))); if(!pPlayerInfo) return; pPlayerInfo->m_Latency = m_Latency.m_Min; pPlayerInfo->m_Local = 1; pPlayerInfo->m_ClientID = FakeID; pPlayerInfo->m_Score = -9999; pPlayerInfo->m_Team = TEAM_SPECTATORS; CNetObj_SpectatorInfo *pSpectatorInfo = static_cast<CNetObj_SpectatorInfo *>(Server()->SnapNewItem(NETOBJTYPE_SPECTATORINFO, FakeID, sizeof(CNetObj_SpectatorInfo))); if(!pSpectatorInfo) return; pSpectatorInfo->m_SpectatorID = m_SpectatorID; pSpectatorInfo->m_X = m_ViewPos.x; pSpectatorInfo->m_Y = m_ViewPos.y; }
void CPlayer::Snap(int SnappingClient) { #ifdef CONF_DEBUG if(!g_Config.m_DbgDummies || m_ClientID < MAX_CLIENTS-g_Config.m_DbgDummies) #endif if(!Server()->ClientIngame(m_ClientID)) return; CNetObj_ClientInfo *pClientInfo = static_cast<CNetObj_ClientInfo *>(Server()->SnapNewItem(NETOBJTYPE_CLIENTINFO, m_ClientID, sizeof(CNetObj_ClientInfo))); if(!pClientInfo) return; StrToInts(&pClientInfo->m_Name0, 6, Server()->ClientName(m_ClientID)); StrToInts(&pClientInfo->m_Skin0, 6, m_TeeInfos.m_SkinName); pClientInfo->m_UseCustomColor = m_TeeInfos.m_UseCustomColor; pClientInfo->m_ColorBody = m_TeeInfos.m_ColorBody; pClientInfo->m_ColorFeet = m_TeeInfos.m_ColorFeet; CNetObj_PlayerInfo *pPlayerInfo = static_cast<CNetObj_PlayerInfo *>(Server()->SnapNewItem(NETOBJTYPE_PLAYERINFO, m_ClientID, sizeof(CNetObj_PlayerInfo))); if(!pPlayerInfo) return; pPlayerInfo->m_Latency = m_Latency.m_Min; pPlayerInfo->m_LatencyFlux = m_Latency.m_Max-m_Latency.m_Min; pPlayerInfo->m_Local = 0; pPlayerInfo->m_ClientID = m_ClientID; if(m_ClientID == SnappingClient) pPlayerInfo->m_Local = 1; // send 0 if times of others are not shown if(SnappingClient != m_ClientID && g_Config.m_SvHideScore) pPlayerInfo->m_Score = 0; else pPlayerInfo->m_Score = m_Score; pPlayerInfo->m_Team = m_Team; }
void CModAPI_WorldEvent_AnimatedText::Send(vec2 Pos, int ItemLayer, const char* pText, int Size, vec4 Color, int Alignment, int AnimationID, int Duration, vec2 Offset) { CNetEvent_ModAPI_AnimatedText *pEvent = (CNetEvent_ModAPI_AnimatedText *)GameServer()->m_Events.Create(NETEVENTTYPE_MODAPI_ANIMATEDTEXT, sizeof(CNetEvent_ModAPI_AnimatedText), GenerateMask()); if(pEvent) { pEvent->m_X = (int)Pos.x; pEvent->m_Y = (int)Pos.y; pEvent->m_ItemLayer = ItemLayer; pEvent->m_Alignment = Alignment; pEvent->m_Color = ModAPI_ColorToInt(Color); pEvent->m_Size = Size; StrToInts(pEvent->m_aText, 16, pText); pEvent->m_AnimationId = AnimationID; pEvent->m_Duration = Duration; pEvent->m_OffsetX = (int)Offset.x; pEvent->m_OffsetY = (int)Offset.y; } }
void CPlayer::Snap(int SnappingClient) { #ifdef CONF_DEBUG if(!g_Config.m_DbgDummies || m_ClientID < MAX_CLIENTS-g_Config.m_DbgDummies) #endif if(!Server()->ClientIngame(m_ClientID)) return; CNetObj_ClientInfo *pClientInfo = static_cast<CNetObj_ClientInfo *>(Server()->SnapNewItem(NETOBJTYPE_CLIENTINFO, m_ClientID, sizeof(CNetObj_ClientInfo))); if(!pClientInfo) return; StrToInts(&pClientInfo->m_Name0, 4, Server()->ClientName(m_ClientID)); int SnapScoreMode = PLAYERSCOREMODE_NORMAL; if(GameServer()->m_apPlayers[SnappingClient]) { SnapScoreMode = GameServer()->m_apPlayers[SnappingClient]->GetScoreMode(); } /* INFECTION MODIFICATION STRAT ***************************************/ int PlayerInfoScore = 0; if(GetTeam() == TEAM_SPECTATORS) { StrToInts(&pClientInfo->m_Clan0, 3, Server()->ClientClan(m_ClientID)); } else { if(SnapScoreMode == PLAYERSCOREMODE_ROUNDSCORE) { char aBuf[512]; str_format(aBuf, sizeof(aBuf), "%s%i pt", (m_ScoreRound > 0 ? "+" : ""), m_ScoreRound); StrToInts(&pClientInfo->m_Clan0, 3, aBuf); PlayerInfoScore = m_ScoreRound; } else if(SnapScoreMode == PLAYERSCOREMODE_TIME) { float RoundDuration = static_cast<float>(m_HumanTime/((float)Server()->TickSpeed()))/60.0f; int Minutes = static_cast<int>(RoundDuration); int Seconds = static_cast<int>((RoundDuration - Minutes)*60.0f); char aBuf[512]; str_format(aBuf, sizeof(aBuf), "%i:%s%i min", Minutes,((Seconds < 10) ? "0" : ""), Seconds); StrToInts(&pClientInfo->m_Clan0, 3, aBuf); PlayerInfoScore = m_HumanTime/Server()->TickSpeed(); } //~ else if(SnapScoreMode == PLAYERSCOREMODE_NBROUND) //~ { //~ char aBuf[512]; //~ str_format(aBuf, sizeof(aBuf), "%i round%s", m_NbRound, (m_NbRound >1 ? "s" : "")); //~ //~ StrToInts(&pClientInfo->m_Clan0, 3, aBuf); //~ //~ PlayerInfoScore = m_NbRound; //~ } else if(SnapScoreMode == PLAYERSCOREMODE_SCOREPERROUND) { float ScorePerRound = static_cast<float>(m_Score)/static_cast<float>(m_NbRound); char aBuf[512]; str_format(aBuf, sizeof(aBuf), "%.2f pt/rnd", ScorePerRound); StrToInts(&pClientInfo->m_Clan0, 3, aBuf); PlayerInfoScore = static_cast<int>(ScorePerRound*10); } else if(SnapScoreMode == PLAYERSCOREMODE_INFECTION) { char aBuf[512]; str_format(aBuf, sizeof(aBuf), "%i inf", m_NbInfection); StrToInts(&pClientInfo->m_Clan0, 3, aBuf); PlayerInfoScore = m_NbInfection; } else if(SnapScoreMode == PLAYERSCOREMODE_INFECTIONPERROUND) { float InfPerRound = static_cast<float>(m_NbInfection)/static_cast<float>(m_NbRound); char aBuf[512]; str_format(aBuf, sizeof(aBuf), "%.2f inf/rnd", InfPerRound); StrToInts(&pClientInfo->m_Clan0, 3, aBuf); PlayerInfoScore = static_cast<int>(InfPerRound*10); } else { switch(GetClass()) { case PLAYERCLASS_ENGINEER: if(m_WinAsHuman) StrToInts(&pClientInfo->m_Clan0, 3, "*Engineer*"); else StrToInts(&pClientInfo->m_Clan0, 3, "Engineer"); break; case PLAYERCLASS_SOLDIER: if(m_WinAsHuman) StrToInts(&pClientInfo->m_Clan0, 3, "*Soldier*"); else StrToInts(&pClientInfo->m_Clan0, 3, "Soldier"); break; case PLAYERCLASS_SCIENTIST: if(m_WinAsHuman) StrToInts(&pClientInfo->m_Clan0, 3, "*Scientist*"); else StrToInts(&pClientInfo->m_Clan0, 3, "Scientist"); break; case PLAYERCLASS_MEDIC: if(m_WinAsHuman) StrToInts(&pClientInfo->m_Clan0, 3, "*Medic*"); else StrToInts(&pClientInfo->m_Clan0, 3, "Medic"); break; case PLAYERCLASS_NINJA: if(m_WinAsHuman) StrToInts(&pClientInfo->m_Clan0, 3, "*Ninja*"); else StrToInts(&pClientInfo->m_Clan0, 3, "Ninja"); break; case PLAYERCLASS_SMOKER: if(m_WinAsHuman) StrToInts(&pClientInfo->m_Clan0, 3, "*Smoker*"); else StrToInts(&pClientInfo->m_Clan0, 3, "Smoker"); break; case PLAYERCLASS_BOOMER: if(m_WinAsHuman) StrToInts(&pClientInfo->m_Clan0, 3, "*Boomer*"); else StrToInts(&pClientInfo->m_Clan0, 3, "Boomer"); break; case PLAYERCLASS_HUNTER: if(m_WinAsHuman) StrToInts(&pClientInfo->m_Clan0, 3, "*Hunter*"); else StrToInts(&pClientInfo->m_Clan0, 3, "Hunter"); break; case PLAYERCLASS_GHOST: if(m_WinAsHuman) StrToInts(&pClientInfo->m_Clan0, 3, "*Ghost*"); else StrToInts(&pClientInfo->m_Clan0, 3, "Ghost"); break; case PLAYERCLASS_UNDEAD: if(m_WinAsHuman) StrToInts(&pClientInfo->m_Clan0, 3, "*Undead*"); else StrToInts(&pClientInfo->m_Clan0, 3, "Undead"); break; case PLAYERCLASS_WITCH: if(m_WinAsHuman) StrToInts(&pClientInfo->m_Clan0, 3, "*Witch*"); else StrToInts(&pClientInfo->m_Clan0, 3, "Witch"); break; default: StrToInts(&pClientInfo->m_Clan0, 3, ""); } PlayerInfoScore = m_Score; } } pClientInfo->m_Country = Server()->ClientCountry(m_ClientID); if( GameServer()->m_apPlayers[SnappingClient] && !IsInfected() && ( (Server()->GetClientCustomSkin(SnappingClient) == 1 && SnappingClient == GetCID()) || (Server()->GetClientCustomSkin(SnappingClient) == 2) ) ) { StrToInts(&pClientInfo->m_Skin0, 6, m_TeeInfos.m_CustomSkinName); } else StrToInts(&pClientInfo->m_Skin0, 6, m_TeeInfos.m_SkinName); pClientInfo->m_UseCustomColor = m_TeeInfos.m_UseCustomColor; pClientInfo->m_ColorBody = m_TeeInfos.m_ColorBody; pClientInfo->m_ColorFeet = m_TeeInfos.m_ColorFeet; /* INFECTION MODIFICATION END *****************************************/ CNetObj_PlayerInfo *pPlayerInfo = static_cast<CNetObj_PlayerInfo *>(Server()->SnapNewItem(NETOBJTYPE_PLAYERINFO, m_ClientID, sizeof(CNetObj_PlayerInfo))); if(!pPlayerInfo) return; pPlayerInfo->m_Latency = SnappingClient == -1 ? m_Latency.m_Min : GameServer()->m_apPlayers[SnappingClient]->m_aActLatency[m_ClientID]; pPlayerInfo->m_Local = 0; pPlayerInfo->m_ClientID = m_ClientID; /* INFECTION MODIFICATION START ***************************************/ pPlayerInfo->m_Score = PlayerInfoScore; /* INFECTION MODIFICATION END *****************************************/ pPlayerInfo->m_Team = m_Team; if(m_ClientID == SnappingClient) pPlayerInfo->m_Local = 1; if(m_ClientID == SnappingClient && m_Team == TEAM_SPECTATORS) { CNetObj_SpectatorInfo *pSpectatorInfo = static_cast<CNetObj_SpectatorInfo *>(Server()->SnapNewItem(NETOBJTYPE_SPECTATORINFO, m_ClientID, sizeof(CNetObj_SpectatorInfo))); if(!pSpectatorInfo) return; pSpectatorInfo->m_SpectatorID = m_SpectatorID; pSpectatorInfo->m_X = m_ViewPos.x; pSpectatorInfo->m_Y = m_ViewPos.y; } }
int CEditorMap::Save(class IStorage *pStorage, const char *pFileName) { char aBuf[256]; str_format(aBuf, sizeof(aBuf), "saving to '%s'...", pFileName); m_pEditor->Console()->Print(IConsole::OUTPUT_LEVEL_STANDARD, "editor", aBuf); CDataFileWriter df; if(!df.Open(pStorage, pFileName)) { str_format(aBuf, sizeof(aBuf), "failed to open file '%s'...", pFileName); m_pEditor->Console()->Print(IConsole::OUTPUT_LEVEL_STANDARD, "editor", aBuf); return 0; } // save version { CMapItemVersion Item; Item.m_Version = 1; df.AddItem(MAPITEMTYPE_VERSION, 0, sizeof(Item), &Item); } // save images for(int i = 0; i < m_lImages.size(); i++) { CEditorImage *pImg = m_lImages[i]; // analyse the image for when saving (should be done when we load the image) // TODO! pImg->AnalyseTileFlags(); CMapItemImage Item; Item.m_Version = 1; Item.m_Width = pImg->m_Width; Item.m_Height = pImg->m_Height; Item.m_External = pImg->m_External; Item.m_ImageName = df.AddData(str_length(pImg->m_aName)+1, pImg->m_aName); if(pImg->m_External) Item.m_ImageData = -1; else Item.m_ImageData = df.AddData(Item.m_Width*Item.m_Height*4, pImg->m_pData); df.AddItem(MAPITEMTYPE_IMAGE, i, sizeof(Item), &Item); } // save layers int LayerCount = 0, GroupCount = 0; for(int g = 0; g < m_lGroups.size(); g++) { CLayerGroup *pGroup = m_lGroups[g]; if(!pGroup->m_SaveToMap) continue; CMapItemGroup GItem; GItem.m_Version = CMapItemGroup::CURRENT_VERSION; GItem.m_ParallaxX = pGroup->m_ParallaxX; GItem.m_ParallaxY = pGroup->m_ParallaxY; GItem.m_OffsetX = pGroup->m_OffsetX; GItem.m_OffsetY = pGroup->m_OffsetY; GItem.m_UseClipping = pGroup->m_UseClipping; GItem.m_ClipX = pGroup->m_ClipX; GItem.m_ClipY = pGroup->m_ClipY; GItem.m_ClipW = pGroup->m_ClipW; GItem.m_ClipH = pGroup->m_ClipH; GItem.m_StartLayer = LayerCount; GItem.m_NumLayers = 0; for(int l = 0; l < pGroup->m_lLayers.size(); l++) { if(!pGroup->m_lLayers[l]->m_SaveToMap) continue; if(pGroup->m_lLayers[l]->m_Type == LAYERTYPE_TILES) { m_pEditor->Console()->Print(IConsole::OUTPUT_LEVEL_ADDINFO, "editor", "saving tiles layer"); CLayerTiles *pLayer = (CLayerTiles *)pGroup->m_lLayers[l]; pLayer->PrepareForSave(); CMapItemLayerTilemap Item; Item.m_Version = 2; Item.m_Layer.m_Flags = pLayer->m_Flags; Item.m_Layer.m_Type = pLayer->m_Type; Item.m_Color.r = pLayer->m_Color.r; Item.m_Color.g = pLayer->m_Color.g; Item.m_Color.b = pLayer->m_Color.b; Item.m_Color.a = pLayer->m_Color.a; Item.m_ColorEnv = -1; // not in use right now Item.m_ColorEnvOffset = 0; Item.m_Width = pLayer->m_Width; Item.m_Height = pLayer->m_Height; Item.m_Flags = pLayer->m_Game; Item.m_Image = pLayer->m_Image; Item.m_Data = df.AddData(pLayer->m_Width*pLayer->m_Height*sizeof(CTile), pLayer->m_pTiles); df.AddItem(MAPITEMTYPE_LAYER, LayerCount, sizeof(Item), &Item); GItem.m_NumLayers++; LayerCount++; } else if(pGroup->m_lLayers[l]->m_Type == LAYERTYPE_QUADS) { m_pEditor->Console()->Print(IConsole::OUTPUT_LEVEL_ADDINFO, "editor", "saving quads layer"); CLayerQuads *pLayer = (CLayerQuads *)pGroup->m_lLayers[l]; if(pLayer->m_lQuads.size()) { CMapItemLayerQuads Item; Item.m_Version = 1; Item.m_Layer.m_Flags = pLayer->m_Flags; Item.m_Layer.m_Type = pLayer->m_Type; Item.m_Image = pLayer->m_Image; // add the data Item.m_NumQuads = pLayer->m_lQuads.size(); Item.m_Data = df.AddDataSwapped(pLayer->m_lQuads.size()*sizeof(CQuad), pLayer->m_lQuads.base_ptr()); df.AddItem(MAPITEMTYPE_LAYER, LayerCount, sizeof(Item), &Item); // clean up //mem_free(quads); GItem.m_NumLayers++; LayerCount++; } } } df.AddItem(MAPITEMTYPE_GROUP, GroupCount++, sizeof(GItem), &GItem); } // save envelopes int PointCount = 0; for(int e = 0; e < m_lEnvelopes.size(); e++) { CMapItemEnvelope Item; Item.m_Version = 1; Item.m_Channels = m_lEnvelopes[e]->m_Channels; Item.m_StartPoint = PointCount; Item.m_NumPoints = m_lEnvelopes[e]->m_lPoints.size(); StrToInts(Item.m_aName, sizeof(Item.m_aName)/sizeof(int), m_lEnvelopes[e]->m_aName); df.AddItem(MAPITEMTYPE_ENVELOPE, e, sizeof(Item), &Item); PointCount += Item.m_NumPoints; } // save points int TotalSize = sizeof(CEnvPoint) * PointCount; CEnvPoint *pPoints = (CEnvPoint *)mem_alloc(TotalSize, 1); PointCount = 0; for(int e = 0; e < m_lEnvelopes.size(); e++) { int Count = m_lEnvelopes[e]->m_lPoints.size(); mem_copy(&pPoints[PointCount], m_lEnvelopes[e]->m_lPoints.base_ptr(), sizeof(CEnvPoint)*Count); PointCount += Count; } df.AddItem(MAPITEMTYPE_ENVPOINTS, 0, TotalSize, pPoints); // finish the data file df.Finish(); m_pEditor->Console()->Print(IConsole::OUTPUT_LEVEL_ADDINFO, "editor", "saving done"); // send rcon.. if we can if(m_pEditor->Client()->RconAuthed()) { CServerInfo CurrentServerInfo; m_pEditor->Client()->GetServerInfo(&CurrentServerInfo); char aMapName[128]; m_pEditor->ExtractName(pFileName, aMapName, sizeof(aMapName)); if(!str_comp(aMapName, CurrentServerInfo.m_aMap)) m_pEditor->Client()->Rcon("reload"); } return 1; }
bool CDataFileWriter::CreateEmptyMap(class IStorage *pStorage, const char *pFileName, int w, int h, CImageInfoFile *pTileset) { dbg_msg("CDataFileWriter", "Saving Empty MineTee Map to '%s'...", pFileName); if(!Open(pStorage, pFileName)) { dbg_msg("CDataFileWriter", "failed to open file '%s'...", pFileName); return 0; } CTile *pTiles = (CTile*)mem_alloc(sizeof(CTile)*w*h, 1); mem_zero(pTiles, sizeof(CTile)*w*h); int LayerCount = 0, GroupCount = 0; // save version { CMapItemVersion Item; Item.m_Version = 1; AddItem(MAPITEMTYPE_VERSION, 0, sizeof(Item), &Item); dbg_msg("CDataFileWriter", "saving version"); } // save map info { CMapItemInfo Item; Item.m_Version = 1; Item.m_Author = -1; Item.m_MapVersion = -1; Item.m_Credits = -1; Item.m_License = -1; AddItem(MAPITEMTYPE_INFO, 0, sizeof(Item), &Item); dbg_msg("CDataFileWriter", "saving info"); } // save images { CMapItemImage Item; Item.m_Version = CMapItemImage::CURRENT_VERSION; char aName[12]; mem_zero(aName,sizeof(aName)); str_copy(aName, "grass_main", sizeof(aName)); Item.m_ImageName = AddData(str_length(aName)+1, aName); if (pTileset && pTileset->m_pData) { Item.m_External = 0; Item.m_Format = pTileset->m_Format; Item.m_Width = pTileset->m_Width; Item.m_Height = pTileset->m_Height; const int PixelSize = pTileset->m_Format == CImageInfoFile::FORMAT_RGB ? 3 : 4; Item.m_ImageData = AddData(Item.m_Width*Item.m_Height*PixelSize, pTileset->m_pData); } else { Item.m_External = 1; Item.m_Format = 1; // RGBA Item.m_Width = 1024; Item.m_Height = 1024; Item.m_ImageData = -1; } AddItem(MAPITEMTYPE_IMAGE, 0, sizeof(Item), &Item); dbg_msg("CDataFileWriter", "saving images"); } // Background Layer { CMapItemGroup GItem; GItem.m_NumLayers = 1; GItem.m_StartLayer = 0; GItem.m_Version = CMapItemGroup::CURRENT_VERSION; GItem.m_ParallaxX = 0; GItem.m_ParallaxY = 0; GItem.m_OffsetX = 0; GItem.m_OffsetY = 0; GItem.m_UseClipping = 0; GItem.m_ClipX = 0; GItem.m_ClipY = 0; GItem.m_ClipW = 0; GItem.m_ClipH = 0; StrToInts(GItem.m_aName, sizeof(GItem.m_aName)/sizeof(int), "\0"); CMapItemLayerQuads Item; Item.m_Image = -1; Item.m_NumQuads = 1; Item.m_Version = 2; Item.m_Layer.m_Flags = 0; Item.m_Layer.m_Type = LAYERTYPE_QUADS; StrToInts(Item.m_aName, sizeof(Item.m_aName)/sizeof(int), "Quads\0"); CQuad QuadBkg; const int Width = 1000000; const int Height = 800000; QuadBkg.m_ColorEnv = -1; QuadBkg.m_ColorEnvOffset = 0; QuadBkg.m_PosEnv = -1; QuadBkg.m_PosEnvOffset = 0; QuadBkg.m_aPoints[0].x = QuadBkg.m_aPoints[2].x = -Width; QuadBkg.m_aPoints[1].x = QuadBkg.m_aPoints[3].x = Width; QuadBkg.m_aPoints[0].y = QuadBkg.m_aPoints[1].y = -Height; QuadBkg.m_aPoints[2].y = QuadBkg.m_aPoints[3].y = Height; QuadBkg.m_aPoints[4].x = QuadBkg.m_aPoints[4].y = 0; QuadBkg.m_aColors[0].r = QuadBkg.m_aColors[1].r = 94; QuadBkg.m_aColors[0].g = QuadBkg.m_aColors[1].g = 132; QuadBkg.m_aColors[0].b = QuadBkg.m_aColors[1].b = 174; QuadBkg.m_aColors[0].a = QuadBkg.m_aColors[1].a = 255; QuadBkg.m_aColors[2].r = QuadBkg.m_aColors[3].r = 204; QuadBkg.m_aColors[2].g = QuadBkg.m_aColors[3].g = 232; QuadBkg.m_aColors[2].b = QuadBkg.m_aColors[3].b = 255; QuadBkg.m_aColors[2].a = QuadBkg.m_aColors[3].a = 255; QuadBkg.m_aTexcoords[0].x = 0; QuadBkg.m_aTexcoords[0].y = 0; QuadBkg.m_aTexcoords[1].x = 1<<10; QuadBkg.m_aTexcoords[1].y = 0; QuadBkg.m_aTexcoords[2].x = 0; QuadBkg.m_aTexcoords[2].y = 1<<10; QuadBkg.m_aTexcoords[3].x = 1<<10; QuadBkg.m_aTexcoords[3].y = 1<<10; Item.m_Data = AddDataSwapped(sizeof(CQuad), &QuadBkg); AddItem(MAPITEMTYPE_LAYER, LayerCount++, sizeof(Item), &Item); AddItem(MAPITEMTYPE_GROUP, GroupCount++, sizeof(GItem), &GItem); dbg_msg("CDataFileWriter", "saving background group"); } // Game Group { CMapItemGroup GItem; GItem.m_Version = CMapItemGroup::CURRENT_VERSION; GItem.m_NumLayers = 4; GItem.m_StartLayer = 1; GItem.m_ParallaxX = 100; GItem.m_ParallaxY = 100; GItem.m_OffsetX = 0; GItem.m_OffsetY = 0; GItem.m_UseClipping = 0; GItem.m_ClipX = 0; GItem.m_ClipY = 0; GItem.m_ClipW = 0; GItem.m_ClipH = 0; StrToInts(GItem.m_aName, sizeof(GItem.m_aName)/sizeof(int), "Game\0"); CMapItemLayerTilemap Item; Item.m_Width = w; Item.m_Height = h; Item.m_Version = 3; Item.m_Color.r=Item.m_Color.g=Item.m_Color.b=Item.m_Color.a=255; Item.m_ColorEnv = -1; Item.m_ColorEnvOffset = 0; Item.m_Layer.m_Flags = 0; Item.m_Layer.m_Type = LAYERTYPE_TILES; // background StrToInts(Item.m_aName, sizeof(Item.m_aName)/sizeof(int), "background\0"); Item.m_Image = 0; Item.m_Flags = 0; Item.m_Data = AddData(w*h*sizeof(CTile), pTiles); AddItem(MAPITEMTYPE_LAYER, LayerCount++, sizeof(Item), &Item); // game StrToInts(Item.m_aName, sizeof(Item.m_aName)/sizeof(int), "Game\0"); Item.m_Image = -1; Item.m_Flags = TILESLAYERFLAG_GAME; Item.m_Data = AddData(w*h*sizeof(CTile), pTiles); AddItem(MAPITEMTYPE_LAYER, LayerCount++, sizeof(Item), &Item); // foreground StrToInts(Item.m_aName, sizeof(Item.m_aName)/sizeof(int), "foreground\0"); Item.m_Image = 0; Item.m_Flags = 0; Item.m_Data = AddData(w*h*sizeof(CTile), pTiles); AddItem(MAPITEMTYPE_LAYER, LayerCount++, sizeof(Item), &Item); AddItem(MAPITEMTYPE_GROUP, GroupCount++, sizeof(GItem), &GItem); dbg_msg("CDataFileWriter", "saving game group"); } mem_free(pTiles); // AddItem(MAPITEMTYPE_ENVPOINTS, 0, 0, 0x0); // finish the data file Finish(); dbg_msg("CDataFileWriter", "Saving Done!"); return true; }
void CPlayer::Snap(int SnappingClient) { #ifdef CONF_DEBUG if(!g_Config.m_DbgDummies || m_ClientID < MAX_CLIENTS-g_Config.m_DbgDummies) #endif if(!Server()->ClientIngame(m_ClientID)) return; int id = m_ClientID; if (SnappingClient > -1 && !Server()->Translate(id, SnappingClient)) return; CNetObj_ClientInfo *pClientInfo = static_cast<CNetObj_ClientInfo *>(Server()->SnapNewItem(NETOBJTYPE_CLIENTINFO, id, sizeof(CNetObj_ClientInfo))); if(!pClientInfo) return; StrToInts(&pClientInfo->m_Name0, 4, Server()->ClientName(m_ClientID)); StrToInts(&pClientInfo->m_Clan0, 3, Server()->ClientClan(m_ClientID)); pClientInfo->m_Country = Server()->ClientCountry(m_ClientID); if (m_StolenSkin && SnappingClient != m_ClientID && g_Config.m_SvSkinStealAction == 1) { StrToInts(&pClientInfo->m_Skin0, 6, "pinky"); pClientInfo->m_UseCustomColor = 0; pClientInfo->m_ColorBody = m_TeeInfos.m_ColorBody; pClientInfo->m_ColorFeet = m_TeeInfos.m_ColorFeet; } else { StrToInts(&pClientInfo->m_Skin0, 6, m_TeeInfos.m_SkinName); pClientInfo->m_UseCustomColor = m_TeeInfos.m_UseCustomColor; pClientInfo->m_ColorBody = m_TeeInfos.m_ColorBody; pClientInfo->m_ColorFeet = m_TeeInfos.m_ColorFeet; } CNetObj_PlayerInfo *pPlayerInfo = static_cast<CNetObj_PlayerInfo *>(Server()->SnapNewItem(NETOBJTYPE_PLAYERINFO, id, sizeof(CNetObj_PlayerInfo))); if(!pPlayerInfo) return; pPlayerInfo->m_Latency = SnappingClient == -1 ? m_Latency.m_Min : GameServer()->m_apPlayers[SnappingClient]->m_aActLatency[m_ClientID]; pPlayerInfo->m_Local = 0; pPlayerInfo->m_ClientID = id; pPlayerInfo->m_Score = abs(m_Score) * -1; pPlayerInfo->m_Team = (m_ClientVersion < VERSION_DDNET_OLD || m_Paused != PAUSED_SPEC || m_ClientID != SnappingClient) && m_Paused < PAUSED_PAUSED ? m_Team : TEAM_SPECTATORS; if(m_ClientID == SnappingClient && (m_Paused != PAUSED_SPEC || m_ClientVersion >= VERSION_DDNET_OLD)) pPlayerInfo->m_Local = 1; if(m_ClientID == SnappingClient && (m_Team == TEAM_SPECTATORS || m_Paused)) { CNetObj_SpectatorInfo *pSpectatorInfo = static_cast<CNetObj_SpectatorInfo *>(Server()->SnapNewItem(NETOBJTYPE_SPECTATORINFO, m_ClientID, sizeof(CNetObj_SpectatorInfo))); if(!pSpectatorInfo) return; pSpectatorInfo->m_SpectatorID = m_SpectatorID; pSpectatorInfo->m_X = m_ViewPos.x; pSpectatorInfo->m_Y = m_ViewPos.y; } // send 0 if times of others are not shown if(SnappingClient != m_ClientID && g_Config.m_SvHideScore) pPlayerInfo->m_Score = -9999; else pPlayerInfo->m_Score = abs(m_Score) * -1; }
void CPlayer::Snap(int SnappingClient) { #ifdef CONF_DEBUG if(!g_Config.m_DbgDummies || m_ClientID < MAX_CLIENTS-g_Config.m_DbgDummies) #endif if(!Server()->ClientIngame(m_ClientID)) return; CNetObj_ClientInfo *pClientInfo = static_cast<CNetObj_ClientInfo *>(Server()->SnapNewItem(NETOBJTYPE_CLIENTINFO, m_ClientID, sizeof(CNetObj_ClientInfo))); if(!pClientInfo) return; StrToInts(&pClientInfo->m_Name0, 4, Server()->ClientName(m_ClientID)); StrToInts(&pClientInfo->m_Clan0, 3, Server()->ClientClan(m_ClientID)); pClientInfo->m_Country = Server()->ClientCountry(m_ClientID); StrToInts(&pClientInfo->m_Skin0, 6, m_TeeInfos.m_SkinName); pClientInfo->m_UseCustomColor = m_TeeInfos.m_UseCustomColor; pClientInfo->m_ColorBody = m_TeeInfos.m_ColorBody; pClientInfo->m_ColorFeet = m_TeeInfos.m_ColorFeet; CNetObj_PlayerInfo *pPlayerInfo = static_cast<CNetObj_PlayerInfo *>(Server()->SnapNewItem(NETOBJTYPE_PLAYERINFO, m_ClientID, sizeof(CNetObj_PlayerInfo))); if(!pPlayerInfo) return; pPlayerInfo->m_Latency = SnappingClient == -1 ? m_Latency.m_Min : GameServer()->m_apPlayers[SnappingClient]->m_aActLatency[m_ClientID]; pPlayerInfo->m_Local = 0; pPlayerInfo->m_ClientID = m_ClientID; pPlayerInfo->m_Score = m_Score; //pPlayerInfo->m_Team = m_Team; if (SnappingClient != GetCID()) pPlayerInfo->m_Team = m_Team; else { if (GetCharacter() || GameServer()->m_pController->IsGameOver()) pPlayerInfo->m_Team = m_Team; else pPlayerInfo->m_Team = TEAM_SPECTATORS; } /* if (SnappingClient == GetCID()) pPlayerInfo->m_Team = m_Team; else pPlayerInfo->m_Team = m_WantedTeam; */ if(m_ClientID == SnappingClient) pPlayerInfo->m_Local = 1; if(m_ClientID == SnappingClient && pPlayerInfo->m_Team == TEAM_SPECTATORS) { CNetObj_SpectatorInfo *pSpectatorInfo = static_cast<CNetObj_SpectatorInfo *>(Server()->SnapNewItem(NETOBJTYPE_SPECTATORINFO, m_ClientID, sizeof(CNetObj_SpectatorInfo))); if(!pSpectatorInfo) { // SPEC_FREEVIEW //pSpectatorInfo->m_X = 0; //pSpectatorInfo->m_Y = 0; } else { pSpectatorInfo->m_SpectatorID = m_SpectatorID; pSpectatorInfo->m_X = m_ViewPos.x; pSpectatorInfo->m_Y = m_ViewPos.y; } } }