From d6ee7ec642cc6b3097c8d321a1a00630e24027d1 Mon Sep 17 00:00:00 2001 From: Stijn Buys Date: Sat, 16 Feb 2008 12:22:33 +0000 Subject: initial client-to-server connection --- src/core/func.cc | 43 +++++++++++++++++++++++-------------------- 1 file changed, 23 insertions(+), 20 deletions(-) (limited to 'src/core/func.cc') diff --git a/src/core/func.cc b/src/core/func.cc index af811cd..06aa5b6 100644 --- a/src/core/func.cc +++ b/src/core/func.cc @@ -11,6 +11,16 @@ namespace core { +Func_t::Func_t(unsigned int funcflags) +{ + func_flags = funcflags; +} + +unsigned int Func_t::flags() +{ + return func_flags; +} + namespace func { @@ -19,35 +29,29 @@ std::map registry; void add(const char * functionname, FuncPtr functionptr, unsigned int flags) { std::map::iterator it = registry.find(functionname); - Func f; if (it == registry.end()) { // function does not yet exist in the registry - f = new Func_t(); + Func f = new Func_t(flags); + //f->name = functionname; + f->ptr = (void *)functionptr; registry[std::string(functionname)] = f; } else { - f = (*it).second; + con_warn << "Function '" << functionname << "' already registered!" << std::endl; } - - f->name = functionname; - f->ptr = (void *)functionptr; - f->flags = flags; } void add(const char * functionname, GameFuncPtr gamefunctionptr, unsigned int flags) { std::map::iterator it = registry.find(functionname); - Func f; if (it == registry.end()) { // function does not yet exist in the registry - f = new Func_t(); + Func f = new Func_t(flags & func::Game); + //f->name = functionname; + f->ptr = (void *)gamefunctionptr; registry[std::string(functionname)] = f; } else { - f = (*it).second; + con_warn << "Function '" << functionname << "' already registered!" << std::endl; } - - f->name = functionname; - f->ptr = (void *)gamefunctionptr; - f->flags = flags & func::Game; } void remove(const char *functionname) @@ -80,15 +84,14 @@ Func find(const std::string &functionname) void list() { - char typeindicator; - std::map::iterator it; for (it = registry.begin(); it != registry.end(); it++) { - if ((*it).second->flags & func::Game) - typeindicator = 'G'; + std::string typeindicator; + if ((*it).second->flags() & func::Game) + typeindicator += 'G'; else - typeindicator = ' '; - con_print << " " << typeindicator << " " << (*it).first << std::endl; + typeindicator += ' '; + con_print << " " << typeindicator << " " << (*it).first << std::endl; } con_print << registry.size() << " registered functions" << std::endl; -- cgit v1.2.3