Planeshift
serversongmngr.h
Go to the documentation of this file.
1 /*
2  * serversongmngr.h, Author: Andrea Rizzi <88whacko@gmail.com>
3  *
4  * Copyright (C) 2001-2011 Atomic Blue (info@planeshift.it, http://www.atomicblue.org)
5  *
6  *
7  * This program is free software; you can redistribute it and/or
8  * modify it under the terms of the GNU General Public License
9  * as published by the Free Software Foundation (version 2 of the License)
10  * This program is distributed in the hope that it will be useful,
11  * but WITHOUT ANY WARRANTY; without even the implied warranty of
12  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13  * GNU General Public License for more details.
14  * You should have received a copy of the GNU General Public License
15  * along with this program; if not, write to the Free Software
16  * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
17  *
18  */
19 
20 #ifndef SERVER_SONG_MANAGER_H
21 #define SERVER_SONG_MANAGER_H
22 
23 
24 //====================================================================================
25 // Project Includes
26 //====================================================================================
27 #include <util/gameevent.h>
28 
29 //====================================================================================
30 // Local Includes
31 //====================================================================================
32 #include "msgmanager.h"
33 
34 //------------------------------------------------------------------------------------
35 // Forward Declarations
36 //------------------------------------------------------------------------------------
37 class psItem;
38 class MathScript;
39 class psCharacter;
40 struct ScoreStatistics;
41 
42 
47 {
48 public:
54  psEndSongEvent(gemActor* charActor, int songLength);
55 
59  virtual ~psEndSongEvent();
60 
61 
62  //From psGameEvent
63  //------------------
64  virtual bool CheckTrigger();
65  virtual void Trigger();
66 
67 private:
68  gemActor* charActor;
69  csTicks startingTime;
70 };
71 
72 
73 //--------------------------------------------------
74 
75 
80 class ServerSongManager: public MessageManager<ServerSongManager>, public Singleton<ServerSongManager>
81 {
82 public:
85 
86  bool Initialize();
87 
93  void HandlePlaySongMessage(MsgEntry* me, Client* client);
94 
100  void HandleStopSongMessage(MsgEntry* me, Client* client);
101 
108  void OnStopSong(gemActor* charActor, bool isEnded);
109 
119  void StopSong(gemActor* charActor, bool skillRanking);
120 
121 private:
122  bool isProcessedSongEnded;
123  MathScript* calcSongPar;
124  MathScript* calcSongExp;
125  unsigned int instrumentsCategory;
126  csHash<int, unsigned int> scoreRanks;
127 
133  psItem* GetEquippedInstrument(psCharacter* charData) const;
134 };
135 
136 #endif // SERVER_SONG_MANAGER_H
137 
A MathScript is a mini-program to run.
Definition: mathscript.h:442
The structure of 1 queue entry (pointer to a message)
Definition: message.h:143
virtual ~psEndSongEvent()
Destructor.
Any semi-autonomous object, either a player or an NPC.
Definition: gem.h:1170
psEndSongEvent(gemActor *charActor, int songLength)
Constructor.
This class collects data of a netclient.
Definition: client.h:95
void void Initialize(iObjectRegistry *object_reg)
This class takes care of played songs and players&#39; ranking for musical instruments skills...
virtual void Trigger()
Abstract event processing function.
This struct keeps general information about a score.
Definition: musicutil.h:43
virtual bool CheckTrigger()
Called right before a Trigger is called.
All scheduled events must inherit from this class.
Definition: gameevent.h:36
This class embodies item instances in the game.
Definition: psitem.h:238
This event informs the song manager when the song is over.
Provides a manager to facilitate subscriptions.
Definition: msgmanager.h:106