Skip to content

Commit 568baba

Browse files
committed
Merge branch 'pepe'
2 parents 55bf5ef + 57486b4 commit 568baba

15 files changed

+172
-200
lines changed

includes/Server.hpp

Lines changed: 7 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -57,11 +57,11 @@ class Server {
5757
std::string _password;
5858
int _socketFd;
5959
struct sockaddr_in _serverAddr;
60-
std::vector<struct pollfd> _fds; //MAX_CLIENTS
60+
std::vector<struct pollfd> _fds; // MAX_CLIENTS
6161
std::map<int, std::string> _inputBuffer;
6262
std::string _creationDate;
6363
std::vector<User *> _users;
64-
std::vector<Channel> _channels;
64+
std::vector<Channel *> _channels;
6565

6666
// Singleton Pattern
6767
static Server *_server;
@@ -99,11 +99,10 @@ class Server {
9999
std::vector<User *> getUsers();
100100

101101
// Channel
102-
std::vector<Channel> &getChannels();
103-
Channel &getChannelByName(const std::string &channelName);
104-
Channel *getChannelByNamePtr(const std::string &channelName);
102+
std::vector<Channel *> &getChannels();
103+
Channel *getChannelByName(const std::string &channelName);
105104
bool channelExists(const std::string &channelName) const;
106-
void addChannel(const Channel &channel);
105+
void addChannel(Channel *channel);
107106
void removeChannel(std::string channelName);
108107

109108
// Disconnection
@@ -120,8 +119,8 @@ class Server {
120119
std::string getCreationDate() const;
121120

122121
// Channel Iterators
123-
std::vector<Channel>::iterator findChannel(const std::string &channelName);
124-
std::vector<Channel>::const_iterator findChannel(const std::string &channelName) const;
122+
std::vector<Channel *>::iterator findChannel(const std::string &channelName);
123+
std::vector<Channel *>::const_iterator findChannel(const std::string &channelName) const;
125124
};
126125

127126
void signalHandler(int signal);

includes/commands/ModeCommand.hpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ class ModeCommand : public ACommand {
2222
private:
2323
const bool _plus;
2424
const bool _showChannelModes;
25-
Channel &_channel;
25+
Channel *_channel;
2626
const std::vector<Mode> _modes;
2727
const std::vector<std::string> _modeParams;
2828

src/Channel.cpp

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -350,13 +350,13 @@ void Channel::removeUser(const std::string &nickname) {
350350
}
351351

352352
if (this->_users.empty() && this->_operators.empty()) {
353-
std::vector<Channel> &serverChannels = server.getChannels();
353+
std::vector<Channel *> serverChannels = server.getChannels();
354354

355355
for (size_t i = 0; i < serverChannels.size(); i++) {
356-
if (serverChannels[i].getName() == this->_name) {
356+
if (serverChannels[i]->getName() == this->_name) {
357357
serverChannels.erase(serverChannels.begin() + i);
358358
break;
359-
}
359+
}
360360
}
361361
}
362362
}

0 commit comments

Comments
 (0)