Files
pvvmud/server/lib/gamelistener.H
2025-03-05 08:37:43 +01:00

96 lines
2.0 KiB
C++

/*
* PVVMUD a 3D MUD
* Copyright (C) 1998-1999 Programvareverkstedet (pvv@pvv.org)
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*
*/
#ifndef _GAMELISTENER_H
#define _GAMELISTENER_H
#include "pvvmud.H"
#include "gameevent.H"
#include "gamefunction.H"
#include "gameobject.H"
#include <list>
#include <hash_map>
class CGameListenerItem {
public:
DWORD s;
CGameFunctionObject *v;
int priority;
CGameListenerItem::CGameListenerItem(DWORD gameObject, CGameFunctionObject
*func, int priority) {
CGameListenerItem();
~CGameListenerItem();
};
class CGameListenerList {
list<CGameListenerItem> listenerList;
public:
CGameListenerList();
~CGameListenerList();
void add(DWORD s, CGameFunctionObject *v, int priority);
void execute(CGameEvent *gameEvent);
};
class CGameListener {
struct _key {
DWORD event;
DWORD object;
} key;
struct eqkey
{
bool operator()(struct _key s1, struct _key s2) const
{
return ( (s1.event==s2.event) && (s1.object==s2.object) );
}
};
typedef listenerHash = hash_map<const char *, CGameListenerList, hash<const
char *>,eqkey);
listenerHash hash;
public:
CGameListener();
~GameListener();
void add(DWORD event, DWORD gameObject, CGameFunctionObject *func,
int priority);
void execute(CGameEvent *gameEvent);
};
#endif _GAMELISTENER_H