Çözüldü Lonca savaşı geri sayım yapma c++

Bu konu çözüme ulaştırılmıştır. Çözüm için konuya yazılan tüm yorumları okumayı unutmayın. Eğer konudaki yorumlar sorununuzu çözmediyse yeni bir konu açabilirsiniz.
Durum
İçerik kilitlendiği için mesaj gönderimine kapatıldı.

therasmus

Üye
Üye
Mesaj
119
Çözümler
10
Beğeni
67
Puan
729
Ticaret Puanı
0
merhaba, lonca savaşında başlaması için geri sayım yapmak istiyorum 3 dk kaldı 1 dk kaldı gibi. nasıl yapabilirim fikir verebilecek var mı acaba?

war_map.cpp de bişeyler denedim ama yemedi açıkcası.
 
Çözüm
Merhaba şöyle bir sistem buldum ama çalışıp çalışmadığından emin değilim. Gerekli yedeklerinizi alıp deneyin. İki türlü paylaşım yapılmış ilk hali standart diğeri ise düzenleme yapılmış.

C++:
* char.cpp

Arat:
    if (m_pWarMap)
        SetWarMap(NULL);

Değiştir:
    if (m_pWarMap) {
        SetWarMap(NULL);

        if (IsAffectFlag(AFF_STUN))
            RemoveAffect(AFFECT_STUN);
    }

---

* char_affect.cpp

Arat:
    DragonSoul_Initialize();

Üstüne ekle:
    CWarMap * warMap = GetWarMap();
    if (warMap && !IsObserverMode())
    {
        warMap->SpawnRandomPos(this);
        if (warMap->GetBeginProtectionStatus() == false)
            AddAffect(AFFECT_STUN, 0, 0, AFF_STUN, 300, 0, 1, 0);
    }



* war_map.cpp

Arat...
Merhaba şöyle bir sistem buldum ama çalışıp çalışmadığından emin değilim. Gerekli yedeklerinizi alıp deneyin. İki türlü paylaşım yapılmış ilk hali standart diğeri ise düzenleme yapılmış.

C++:
* char.cpp

Arat:
    if (m_pWarMap)
        SetWarMap(NULL);

Değiştir:
    if (m_pWarMap) {
        SetWarMap(NULL);

        if (IsAffectFlag(AFF_STUN))
            RemoveAffect(AFFECT_STUN);
    }

---

* char_affect.cpp

Arat:
    DragonSoul_Initialize();

Üstüne ekle:
    CWarMap * warMap = GetWarMap();
    if (warMap && !IsObserverMode())
    {
        warMap->SpawnRandomPos(this);
        if (warMap->GetBeginProtectionStatus() == false)
            AddAffect(AFFECT_STUN, 0, 0, AFF_STUN, 300, 0, 1, 0);
    }



* war_map.cpp

Arat:
EVENTFUNC(war_begin_event)
{
    war_map_info* info = dynamic_cast<war_map_info*>( event->info );

    if ( info == NULL )
    {
        sys_err( "war_begin_event> <Factor> Null pointer" );
        return 0;
    }

    CWarMap * pMap = info->pWarMap;
    pMap->CheckWarEnd();

    return PASSES_PER_SEC(10);
}

Altına ekle:
EVENTFUNC(war_begin_protection_event)
{
    war_map_info* info = dynamic_cast<war_map_info*>(event->info);

    if (info == NULL)
    {
        sys_err("war_begin_protection_event> <Factor> Null pointer");
        return 0;
    }

    CWarMap * pMap = info->pWarMap;

    if (pMap->GetBeginProtectionStatus() == false)
    {
        DWORD dwElapsedTime = get_dword_time() - pMap->GetStartTime();
        if (dwElapsedTime >= 60000) {
            pMap->RemoveStuns();
            pMap->SetBeginProtectionStatus(true);
            pMap->Notice("Savas basladi!");
        }
        else {
            char szNoticeText[512];
            snprintf(szNoticeText, sizeof(szNoticeText), "Savas %ld saniye icinde baslayacak.", 60 - (dwElapsedTime / 1000));
            pMap->Notice(szNoticeText);
        }
    }

    return PASSES_PER_SEC(10);
}

---

Arat:
void CWarMap::SetBeginEvent(LPEVENT pkEv)
{
    if (m_pkBeginEvent != NULL) {
        event_cancel(&m_pkBeginEvent);
    }
    if (pkEv != NULL) {
        m_pkBeginEvent = pkEv;
    }
}

Altına Ekle:
void CWarMap::SetBeginProtectionEvent(LPEVENT pkEv)
{
    if (m_pkBeginProtectionEvent != NULL) {
        event_cancel(&m_pkBeginProtectionEvent);
    }
    if (pkEv != NULL) {
        m_pkBeginProtectionEvent = pkEv;
    }
}

---

Arat:
    event_cancel(&m_pkBeginEvent);

Altına ekle:
    event_cancel(&m_pkBeginProtectionEvent);


---

Arat:
    SetBeginEvent(event_create(war_begin_event, info, PASSES_PER_SEC(60)));

Altına ekle:
    war_begin_protection_event = NULL;

---

Arat:
    m_dwStartTime = get_dword_time();
    m_bEnded = false;

Altına ekle:
    m_bBeginProtectionCompleted = false;

---

Arat:
void CWarMap::IncMember(LPCHARACTER ch)

Bul:
    if (isWarMember)
    {

Altına ekle:
        if (m_set_pkChr.empty()) {
            m_dwFirstLogonTime = get_dword_time();
            SetBeginProtectionEvent(event_create(war_begin_protection_event, info, PASSES_PER_SEC(1)));
        }

---

Arat:
void CWarMap::DecMember(LPCHARACTER ch)
{
    ...
}

Altına ekle:
void CWarMap::SpawnRandomPos(LPCHARACTER ch)
{
    if (!ch)
        return;

    int iAttemptCount = 0;
    PIXEL_POSITION pos;
    for (;;)
    {
        if (iAttemptCount++ == 5)
            break;

        pos.x = number(ch->GetX() - 200, ch->GetX() + 200);
        pos.y = number(ch->GetY() - 100, ch->GetY() + 100);
        if (SECTREE_MANAGER::instance().IsMovablePosition(ch->GetMapIndex(), pos.x, pos.y))
        {

            ch->Show(ch->GetMapIndex(), pos.x, pos.y);
            ch->Stop();
            break;
        }
    }
}

void CWarMap::RemoveStuns()
{
    itertype(m_set_pkChr) it = m_set_pkChr.begin();

    while (it != m_set_pkChr.end())
    {
        LPCHARACTER ch = *(it++);
        if (ch && ch->IsAffectFlag(AFF_STUN))
            ch->RemoveAffect(AFFECT_STUN);
    }
}

DWORD CWarMap::GetStartTime()
{
    return m_dwFirstLogonTime;
}

bool CWarMap::GetBeginProtectionStatus()
{
    return m_bBeginProtectionCompleted;
}

void CWarMap::SetBeginProtectionStatus(bool bNewStat)
{
    m_bBeginProtectionCompleted = bNewStat;
}

---

Arat:
void CWarMap::ExitAll()
{

Altına ekle:
    RemoveStuns();

---

* war_map.h

Arat:
        void    SetBeginEvent(LPEVENT pkEv);

Altına ekle:
        void    SetBeginProtectionEvent(LPEVENT pkEv);

---

Arat:
        LPEVENT        m_pkBeginEvent;

Altına ekle:
        LPEVENT        m_pkBeginProtectionEvent;

---

Arat:
        void    DecMember(LPCHARACTER ch);

Altına ekle:
        void    SpawnRandomPos(LPCHARACTER ch);
        void    RemoveStuns();

        DWORD    GetStartTime();
        bool    GetBeginProtectionStatus();
        void    SetBeginProtectionStatus(bool bNewStat);

---

Arat:
        bool        m_bEnded;

Altına ekle:
        bool        m_bBeginProtectionCompleted;
        DWORD         m_dwFirstLogonTime;

C++:
* war_map.h

Arat:
        void    RemoveStuns();

Altına ekle:
        PIXEL_POSITION    GetStartPosition(LPCHARACTER ch);
        void            RewarpCharsToStartPos();

---

Arat:
        bool        m_bBeginProtectionCompleted;

Altına ekle:
        std::map<LPCHARACTER, PIXEL_POSITION> m_StartPositions;

---

* war_map.cpp

Arat:
    m_bBeginProtectionCompleted = true;

Altına ekle:
    m_StartPositions.clear();

---

Arat:
    m_set_pkChr.clear();

Altına ekle:
    m_StartPositions.clear();

---

Arat:
    m_set_pkChr.insert(ch);

Altına ekle:
    if (m_StartPositions.find(ch) != m_StartPositions.end())
        m_StartPositions.erase(ch);
    m_StartPositions[ch] = ch->GetXYZ();

---

Arat:
    m_set_pkChr.erase(ch);

Altına ekle:
    m_StartPositions.erase(ch);

---

Arat:
                LPCHARACTER tch = *(it++);
                if (tch && tch->GetX() != pos.x && tch->GetY() != pos.y)
                {
                    ch->Show(ch->GetMapIndex(), pos.x, pos.y);
                    ch->Stop();
                    break;
                }

Değiştir:
                LPCHARACTER tch = *(it++);
                if (tch && tch->GetX() != pos.x && tch->GetY() != pos.y)
                {
                    ch->Show(ch->GetMapIndex(), pos.x, pos.y);
                    ch->Stop();

                    if (m_StartPositions.find(ch) != m_StartPositions.end())
                        m_StartPositions.erase(ch);
                    m_StartPositions[ch] = ch->GetXYZ();

                    break;
                }

---

Arat:
void CWarMap::RemoveStuns()
{
    itertype(m_set_pkChr) it = m_set_pkChr.begin();

    while (it != m_set_pkChr.end())
    {
        LPCHARACTER ch = *(it++);
        if (ch && ch->IsAffectFlag(AFF_STUN))
            ch->RemoveAffect(AFFECT_STUN);
    }
}

Altına ekle:
PIXEL_POSITION CWarMap::GetStartPosition(LPCHARACTER ch)
{
    if (m_StartPositions.find(ch) != m_StartPositions.end())
        return m_StartPositions[ch];
    return ch->GetXYZ();
}

void CWarMap::RewarpCharsToStartPos()
{
    itertype(m_set_pkChr) it = m_set_pkChr.begin();

    while (it != m_set_pkChr.end())
    {
        LPCHARACTER ch = *(it++);

        if (ch && !ch->IsObserverMode())
        {
            PIXEL_POSITION pos = GetStartPosition(ch);
            if (pos.x != ch->GetX() || pos.y != ch->GetY())
            {
                ch->Show(ch->GetMapIndex(), pos.x, pos.y);
                ch->Stop();
                sys_err("Hareket etmis oyuncu! %s[%ld] -> %ld - %ld | %ld - %ld", ch->GetName(), ch->GetPlayerID(), pos.x, ch->GetX(), pos.y, ch->GetY());
            }
        }
    }
}

---

Arat:
        DWORD dwElapsedTime = get_dword_time() - pMap->GetStartTime();
        if (dwElapsedTime >= 60000) {
            pMap->RemoveStuns();
            pMap->SetBeginProtectionStatus(true);
            pMap->Notice("Savas basladi!");
        }

Değiştir:
        DWORD dwElapsedTime = get_dword_time() - pMap->GetStartTime();
        if (dwElapsedTime >= 60000) {
            pMap->RemoveStuns();
            pMap->RewarpCharsToStartPos();
            pMap->SetBeginProtectionStatus(true);
            pMap->Notice("Savas basladi!");
        }
 
Çözüm
Merhaba şöyle bir sistem buldum ama çalışıp çalışmadığından emin değilim. Gerekli yedeklerinizi alıp deneyin. İki türlü paylaşım yapılmış ilk hali standart diğeri ise düzenleme yapılmış.

C++:
* char.cpp

Arat:
    if (m_pWarMap)
        SetWarMap(NULL);

Değiştir:
    if (m_pWarMap) {
        SetWarMap(NULL);

        if (IsAffectFlag(AFF_STUN))
            RemoveAffect(AFFECT_STUN);
    }

---

* char_affect.cpp

Arat:
    DragonSoul_Initialize();

Üstüne ekle:
    CWarMap * warMap = GetWarMap();
    if (warMap && !IsObserverMode())
    {
        warMap->SpawnRandomPos(this);
        if (warMap->GetBeginProtectionStatus() == false)
            AddAffect(AFFECT_STUN, 0, 0, AFF_STUN, 300, 0, 1, 0);
    }



* war_map.cpp

Arat:
EVENTFUNC(war_begin_event)
{
    war_map_info* info = dynamic_cast<war_map_info*>( event->info );

    if ( info == NULL )
    {
        sys_err( "war_begin_event> <Factor> Null pointer" );
        return 0;
    }

    CWarMap * pMap = info->pWarMap;
    pMap->CheckWarEnd();

    return PASSES_PER_SEC(10);
}

Altına ekle:
EVENTFUNC(war_begin_protection_event)
{
    war_map_info* info = dynamic_cast<war_map_info*>(event->info);

    if (info == NULL)
    {
        sys_err("war_begin_protection_event> <Factor> Null pointer");
        return 0;
    }

    CWarMap * pMap = info->pWarMap;

    if (pMap->GetBeginProtectionStatus() == false)
    {
        DWORD dwElapsedTime = get_dword_time() - pMap->GetStartTime();
        if (dwElapsedTime >= 60000) {
            pMap->RemoveStuns();
            pMap->SetBeginProtectionStatus(true);
            pMap->Notice("Savas basladi!");
        }
        else {
            char szNoticeText[512];
            snprintf(szNoticeText, sizeof(szNoticeText), "Savas %ld saniye icinde baslayacak.", 60 - (dwElapsedTime / 1000));
            pMap->Notice(szNoticeText);
        }
    }

    return PASSES_PER_SEC(10);
}

---

Arat:
void CWarMap::SetBeginEvent(LPEVENT pkEv)
{
    if (m_pkBeginEvent != NULL) {
        event_cancel(&m_pkBeginEvent);
    }
    if (pkEv != NULL) {
        m_pkBeginEvent = pkEv;
    }
}

Altına Ekle:
void CWarMap::SetBeginProtectionEvent(LPEVENT pkEv)
{
    if (m_pkBeginProtectionEvent != NULL) {
        event_cancel(&m_pkBeginProtectionEvent);
    }
    if (pkEv != NULL) {
        m_pkBeginProtectionEvent = pkEv;
    }
}

---

Arat:
    event_cancel(&m_pkBeginEvent);

Altına ekle:
    event_cancel(&m_pkBeginProtectionEvent);


---

Arat:
    SetBeginEvent(event_create(war_begin_event, info, PASSES_PER_SEC(60)));

Altına ekle:
    war_begin_protection_event = NULL;

---

Arat:
    m_dwStartTime = get_dword_time();
    m_bEnded = false;

Altına ekle:
    m_bBeginProtectionCompleted = false;

---

Arat:
void CWarMap::IncMember(LPCHARACTER ch)

Bul:
    if (isWarMember)
    {

Altına ekle:
        if (m_set_pkChr.empty()) {
            m_dwFirstLogonTime = get_dword_time();
            SetBeginProtectionEvent(event_create(war_begin_protection_event, info, PASSES_PER_SEC(1)));
        }

---

Arat:
void CWarMap::DecMember(LPCHARACTER ch)
{
    ...
}

Altına ekle:
void CWarMap::SpawnRandomPos(LPCHARACTER ch)
{
    if (!ch)
        return;

    int iAttemptCount = 0;
    PIXEL_POSITION pos;
    for (;;)
    {
        if (iAttemptCount++ == 5)
            break;

        pos.x = number(ch->GetX() - 200, ch->GetX() + 200);
        pos.y = number(ch->GetY() - 100, ch->GetY() + 100);
        if (SECTREE_MANAGER::instance().IsMovablePosition(ch->GetMapIndex(), pos.x, pos.y))
        {

            ch->Show(ch->GetMapIndex(), pos.x, pos.y);
            ch->Stop();
            break;
        }
    }
}

void CWarMap::RemoveStuns()
{
    itertype(m_set_pkChr) it = m_set_pkChr.begin();

    while (it != m_set_pkChr.end())
    {
        LPCHARACTER ch = *(it++);
        if (ch && ch->IsAffectFlag(AFF_STUN))
            ch->RemoveAffect(AFFECT_STUN);
    }
}

DWORD CWarMap::GetStartTime()
{
    return m_dwFirstLogonTime;
}

bool CWarMap::GetBeginProtectionStatus()
{
    return m_bBeginProtectionCompleted;
}

void CWarMap::SetBeginProtectionStatus(bool bNewStat)
{
    m_bBeginProtectionCompleted = bNewStat;
}

---

Arat:
void CWarMap::ExitAll()
{

Altına ekle:
    RemoveStuns();

---

* war_map.h

Arat:
        void    SetBeginEvent(LPEVENT pkEv);

Altına ekle:
        void    SetBeginProtectionEvent(LPEVENT pkEv);

---

Arat:
        LPEVENT        m_pkBeginEvent;

Altına ekle:
        LPEVENT        m_pkBeginProtectionEvent;

---

Arat:
        void    DecMember(LPCHARACTER ch);

Altına ekle:
        void    SpawnRandomPos(LPCHARACTER ch);
        void    RemoveStuns();

        DWORD    GetStartTime();
        bool    GetBeginProtectionStatus();
        void    SetBeginProtectionStatus(bool bNewStat);

---

Arat:
        bool        m_bEnded;

Altına ekle:
        bool        m_bBeginProtectionCompleted;
        DWORD         m_dwFirstLogonTime;

C++:
* war_map.h

Arat:
        void    RemoveStuns();

Altına ekle:
        PIXEL_POSITION    GetStartPosition(LPCHARACTER ch);
        void            RewarpCharsToStartPos();

---

Arat:
        bool        m_bBeginProtectionCompleted;

Altına ekle:
        std::map<LPCHARACTER, PIXEL_POSITION> m_StartPositions;

---

* war_map.cpp

Arat:
    m_bBeginProtectionCompleted = true;

Altına ekle:
    m_StartPositions.clear();

---

Arat:
    m_set_pkChr.clear();

Altına ekle:
    m_StartPositions.clear();

---

Arat:
    m_set_pkChr.insert(ch);

Altına ekle:
    if (m_StartPositions.find(ch) != m_StartPositions.end())
        m_StartPositions.erase(ch);
    m_StartPositions[ch] = ch->GetXYZ();

---

Arat:
    m_set_pkChr.erase(ch);

Altına ekle:
    m_StartPositions.erase(ch);

---

Arat:
                LPCHARACTER tch = *(it++);
                if (tch && tch->GetX() != pos.x && tch->GetY() != pos.y)
                {
                    ch->Show(ch->GetMapIndex(), pos.x, pos.y);
                    ch->Stop();
                    break;
                }

Değiştir:
                LPCHARACTER tch = *(it++);
                if (tch && tch->GetX() != pos.x && tch->GetY() != pos.y)
                {
                    ch->Show(ch->GetMapIndex(), pos.x, pos.y);
                    ch->Stop();

                    if (m_StartPositions.find(ch) != m_StartPositions.end())
                        m_StartPositions.erase(ch);
                    m_StartPositions[ch] = ch->GetXYZ();

                    break;
                }

---

Arat:
void CWarMap::RemoveStuns()
{
    itertype(m_set_pkChr) it = m_set_pkChr.begin();

    while (it != m_set_pkChr.end())
    {
        LPCHARACTER ch = *(it++);
        if (ch && ch->IsAffectFlag(AFF_STUN))
            ch->RemoveAffect(AFFECT_STUN);
    }
}

Altına ekle:
PIXEL_POSITION CWarMap::GetStartPosition(LPCHARACTER ch)
{
    if (m_StartPositions.find(ch) != m_StartPositions.end())
        return m_StartPositions[ch];
    return ch->GetXYZ();
}

void CWarMap::RewarpCharsToStartPos()
{
    itertype(m_set_pkChr) it = m_set_pkChr.begin();

    while (it != m_set_pkChr.end())
    {
        LPCHARACTER ch = *(it++);

        if (ch && !ch->IsObserverMode())
        {
            PIXEL_POSITION pos = GetStartPosition(ch);
            if (pos.x != ch->GetX() || pos.y != ch->GetY())
            {
                ch->Show(ch->GetMapIndex(), pos.x, pos.y);
                ch->Stop();
                sys_err("Hareket etmis oyuncu! %s[%ld] -> %ld - %ld | %ld - %ld", ch->GetName(), ch->GetPlayerID(), pos.x, ch->GetX(), pos.y, ch->GetY());
            }
        }
    }
}

---

Arat:
        DWORD dwElapsedTime = get_dword_time() - pMap->GetStartTime();
        if (dwElapsedTime >= 60000) {
            pMap->RemoveStuns();
            pMap->SetBeginProtectionStatus(true);
            pMap->Notice("Savas basladi!");
        }

Değiştir:
        DWORD dwElapsedTime = get_dword_time() - pMap->GetStartTime();
        if (dwElapsedTime >= 60000) {
            pMap->RemoveStuns();
            pMap->RewarpCharsToStartPos();
            pMap->SetBeginProtectionStatus(true);
            pMap->Notice("Savas basladi!");
        }
çit sisteminin bir kısmı bu sanırım
 
Durum
İçerik kilitlendiği için mesaj gönderimine kapatıldı.
Geri
Üst