Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

Ignore:
Timestamp:
May 28, 2009, 1:58:22 AM (16 years ago)
Author:
landauf
Message:

Added Gameplay messages (Announces, Killmessages and Deathmessages)

Location:
code/trunk/src/orxonox/objects/infos
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • code/trunk/src/orxonox/objects/infos/GametypeInfo.cc

    r2826 r3099  
    3131
    3232#include "core/CoreIncludes.h"
     33#include "core/GameMode.h"
     34#include "network/NetworkFunction.h"
     35#include "network/Host.h"
     36#include "objects/GametypeMessageListener.h"
    3337
    3438namespace orxonox
    3539{
    3640    CreateUnloadableFactory(GametypeInfo);
     41
     42    registerMemberNetworkFunction(GametypeInfo, dispatchAnnounceMessage);
     43    registerMemberNetworkFunction(GametypeInfo, dispatchKillMessage);
     44    registerMemberNetworkFunction(GametypeInfo, dispatchDeathMessage);
    3745
    3846    GametypeInfo::GametypeInfo(BaseObject* creator) : Info(creator)
     
    6068        registerVariable(this->hudtemplate_,            variableDirection::toclient);
    6169    }
     70
     71    void GametypeInfo::sendAnnounceMessage(const std::string& message) const
     72    {
     73        if (GameMode::isMaster())
     74        {
     75            callMemberNetworkFunction(GametypeInfo, dispatchAnnounceMessage, this->getObjectID(), CLIENTID_UNKNOWN, message);
     76            this->dispatchAnnounceMessage(message);
     77        }
     78    }
     79
     80    void GametypeInfo::sendAnnounceMessage(const std::string& message, unsigned int clientID) const
     81    {
     82        if (GameMode::isMaster())
     83        {
     84            if (clientID == CLIENTID_SERVER)
     85                this->dispatchAnnounceMessage(message);
     86            else
     87                callMemberNetworkFunction(GametypeInfo, dispatchAnnounceMessage, this->getObjectID(), clientID, message);
     88        }
     89    }
     90
     91    void GametypeInfo::sendKillMessage(const std::string& message, unsigned int clientID) const
     92    {
     93        if (GameMode::isMaster())
     94        {
     95            if (clientID == CLIENTID_SERVER)
     96                this->dispatchKillMessage(message);
     97            else
     98                callMemberNetworkFunction(GametypeInfo, dispatchKillMessage, this->getObjectID(), clientID, message);
     99        }
     100    }
     101
     102    void GametypeInfo::sendDeathMessage(const std::string& message, unsigned int clientID) const
     103    {
     104        if (GameMode::isMaster())
     105        {
     106            if (clientID == CLIENTID_SERVER)
     107                this->dispatchDeathMessage(message);
     108            else
     109                callMemberNetworkFunction(GametypeInfo, dispatchDeathMessage, this->getObjectID(), clientID, message);
     110        }
     111    }
     112
     113    void GametypeInfo::dispatchAnnounceMessage(const std::string& message) const
     114    {
     115        for (ObjectList<GametypeMessageListener>::iterator it = ObjectList<GametypeMessageListener>::begin(); it != ObjectList<GametypeMessageListener>::end(); ++it)
     116            it->announcemessage(this, message);
     117    }
     118
     119    void GametypeInfo::dispatchKillMessage(const std::string& message) const
     120    {
     121        for (ObjectList<GametypeMessageListener>::iterator it = ObjectList<GametypeMessageListener>::begin(); it != ObjectList<GametypeMessageListener>::end(); ++it)
     122            it->killmessage(this, message);
     123    }
     124
     125    void GametypeInfo::dispatchDeathMessage(const std::string& message) const
     126    {
     127        for (ObjectList<GametypeMessageListener>::iterator it = ObjectList<GametypeMessageListener>::begin(); it != ObjectList<GametypeMessageListener>::end(); ++it)
     128            it->deathmessage(this, message);
     129    }
    62130}
  • code/trunk/src/orxonox/objects/infos/GametypeInfo.h

    r2826 r3099  
    5959                { return this->hudtemplate_; }
    6060
     61            void sendAnnounceMessage(const std::string& message) const;
     62            void sendAnnounceMessage(const std::string& message, unsigned int clientID) const;
     63            void sendKillMessage(const std::string& message, unsigned int clientID) const;
     64            void sendDeathMessage(const std::string& message, unsigned int clientID) const;
     65
     66            void dispatchAnnounceMessage(const std::string& message) const;
     67            void dispatchKillMessage(const std::string& message) const;
     68            void dispatchDeathMessage(const std::string& message) const;
     69
    6170        private:
    6271            bool bStarted_;
Note: See TracChangeset for help on using the changeset viewer.