64 lines
2.0 KiB
C++
64 lines
2.0 KiB
C++
// Copyright (C) 2007-2025 EQ2EMulator
|
|
// Licensed under GPL v3
|
|
|
|
#ifndef CHAT_CHATCHANNEL_H_
|
|
#define CHAT_CHATCHANNEL_H_
|
|
|
|
#include "../../common/types.h"
|
|
#include "../client.h"
|
|
#include <vector>
|
|
|
|
using namespace std;
|
|
|
|
#define CHAT_CHANNEL_MAX_NAME 100
|
|
#define CHAT_CHANNEL_MAX_PASSWORD 100
|
|
|
|
enum ChatChannelType {
|
|
CHAT_CHANNEL_TYPE_NONE = 0,
|
|
CHAT_CHANNEL_TYPE_WORLD,
|
|
CHAT_CHANNEL_TYPE_CUSTOM
|
|
};
|
|
|
|
class ChatChannel {
|
|
public:
|
|
ChatChannel();
|
|
virtual ~ChatChannel();
|
|
|
|
void SetName(const char *name) {strncpy(this->name, name, CHAT_CHANNEL_MAX_NAME);}
|
|
void SetPassword(const char *password) {strncpy(this->password, password, CHAT_CHANNEL_MAX_PASSWORD);}
|
|
void SetType(ChatChannelType type) {this->type = type;}
|
|
void SetLevelRestriction(int16 level_restriction) {this->level_restriction = level_restriction;}
|
|
void SetRacesAllowed(int64 races) {this->races = races;}
|
|
void SetClassesAllowed(int64 classes) {this->classes = classes;}
|
|
|
|
const char * GetName() {return name;}
|
|
ChatChannelType GetType() {return type;}
|
|
unsigned int GetNumClients() {return clients.size();}
|
|
|
|
bool HasPassword() {return password[0] != '\0';}
|
|
bool PasswordMatches(const char *password) {return strncmp(this->password, password, CHAT_CHANNEL_MAX_PASSWORD) == 0;}
|
|
bool CanJoinChannelByLevel(int16 level) {return level >= level_restriction;}
|
|
bool CanJoinChannelByRace(int8 race_id) {return races == 0 || (1 << race_id) & races;}
|
|
bool CanJoinChannelByClass(int8 class_id) {return classes == 0 || (1 << class_id) & classes;}
|
|
|
|
bool IsInChannel(int32 character_id);
|
|
bool JoinChannel(Client *client);
|
|
bool LeaveChannel(Client *client);
|
|
bool TellChannel(std::string charName, int8 charLanguage, const char *message, const char* name2 = 0);
|
|
bool TellChannelClient(Client* to_client, const char* message, const char* name2 = 0);
|
|
|
|
bool SendChannelUserList(Client *client);
|
|
|
|
|
|
private:
|
|
char name[CHAT_CHANNEL_MAX_NAME + 1];
|
|
char password[CHAT_CHANNEL_MAX_PASSWORD + 1];
|
|
ChatChannelType type;
|
|
vector<int32> clients;
|
|
int16 level_restriction;
|
|
int64 races;
|
|
int64 classes;
|
|
};
|
|
|
|
#endif
|