Updated Makefile, restructured code
This commit is contained in:
parent
658aebf932
commit
398aa7d46f
3
.gitignore
vendored
3
.gitignore
vendored
@ -1,2 +1 @@
|
||||
*.o
|
||||
xnoircd
|
||||
build
|
31
Makefile
31
Makefile
@ -1,29 +1,18 @@
|
||||
FLAGS = -pthread
|
||||
OFLAGS = -g
|
||||
|
||||
xnoircd: user.o nameable.o channel.o connection.o ircserver.o irccommand.o userconnection.o main.o
|
||||
g++ $(FLAGS) user.o nameable.o channel.o connection.o ircserver.o irccommand.o userconnection.o main.o -o $@
|
||||
XNOIRDC_CPP_SRCS = $(shell find src/ -name '*.cpp')
|
||||
XNOIRDC_CPP_OBJS = $(patsubst src/%.cpp,build/%.o,$(XNOIRDC_CPP_SRCS))
|
||||
|
||||
user.o: user.cpp user.h
|
||||
g++ $(OFLAGS) -c $*.cpp
|
||||
XNOIRDC_OBJS = $(XNOIRDC_CPP_OBJS)
|
||||
|
||||
connection.o: connection.cpp connection.h
|
||||
g++ $(OFLAGS) -c $*.cpp
|
||||
.PHONY: clean
|
||||
|
||||
ircserver.o: ircserver.cpp ircserver.h
|
||||
g++ $(OFLAGS) -c $*.cpp
|
||||
build/xnoircd: $(XNOIRDC_OBJS)
|
||||
g++ $(FLAGS) $^ -o $@
|
||||
|
||||
irccommand.o: irccommand.cpp irccommand.h
|
||||
g++ $(OFLAGS) -c $*.cpp
|
||||
build/%.o: src/%.cpp
|
||||
g++ -c $< -o $@
|
||||
|
||||
userconnection.o: userconnection.cpp userconnection.h
|
||||
g++ $(OFLAGS) -c $*.cpp
|
||||
|
||||
nameable.o: nameable.cpp nameable.h
|
||||
g++ $(OFLAGS) -c $*.cpp
|
||||
|
||||
channel.o: channel.cpp channel.h
|
||||
g++ $(OFLAGS) -c $*.cpp
|
||||
|
||||
main.o: main.cpp
|
||||
g++ $(OFLAGS) -c $*.cpp
|
||||
clean:
|
||||
rm *.o
|
||||
|
@ -1,7 +1,5 @@
|
||||
#include "irccommand.h"
|
||||
|
||||
#include <iostream>
|
||||
|
||||
IRCCommand::IRCCommand() {}
|
||||
IRCCommand::IRCCommand(std::string raw_command) {
|
||||
if (raw_command[0] == '@') {
|
||||
@ -56,14 +54,6 @@ IRCCommand::IRCCommand(std::string source, std::string command) {
|
||||
this->source = source;
|
||||
this->command = command;
|
||||
}
|
||||
/*
|
||||
template<typename... T>
|
||||
IRCCommand::IRCCommand(std::string source, std::string command, T... params) {
|
||||
this->source = source;
|
||||
this->command = command;
|
||||
this->parameters = {params...};
|
||||
}
|
||||
*/
|
||||
|
||||
IRCCommand::~IRCCommand() {
|
||||
this->parameters.clear();
|
@ -62,6 +62,7 @@ std::vector<IRCCommand> User::user_cmd(IRCCommand cmd) {
|
||||
auto motd = motd_cmd(IRCCommand());
|
||||
|
||||
to_return.insert(to_return.end(), motd.begin(), motd.end());
|
||||
|
||||
return to_return;
|
||||
}
|
||||
|
||||
@ -200,13 +201,11 @@ std::vector<IRCCommand> User::motd_cmd(IRCCommand cmd) {
|
||||
std::vector<IRCCommand> User::process_cmd(IRCCommand cmd) {
|
||||
auto command = commands.find(cmd.get_command());
|
||||
|
||||
if (command == commands.end()) {
|
||||
if (command == commands.end())
|
||||
return {IRCCommand(server->get_hostname(), "421", get_nick(), cmd.get_command(), "Unknown Command.")};
|
||||
}
|
||||
|
||||
if (cmd.get_parameter_count() < std::get<0>(command->second)) {
|
||||
if (cmd.get_parameter_count() < std::get<0>(command->second))
|
||||
return {IRCCommand(server->get_hostname(), "461", get_nick(), cmd.get_command(), "Too few parameters.")};
|
||||
}
|
||||
|
||||
if (this->state == Initial && std::get<2>(command->second))
|
||||
return {};
|
Loading…
x
Reference in New Issue
Block a user