/* * Copyright (c) 2002, Stefan Farfeleder * $Id: server_util.cc,v 1.3 2002/09/17 17:15:05 stefan Exp $ */ #include #include #include "config.h" #include "item_s.h" #include "object_s.h" #include "obstacle_s.h" #include "server_util.h" #include "weapon_s.h" using std::string; using namespace JFK::server; objpair::objpair(objhandle objh) { oh[0] = objh; oh[1] = objh.clone(); } objpair::objpair(const objpair& op) { oh[0] = op.oh[0]; oh[1] = op.oh[1]; } objpair& objpair::operator=(const objpair& op) { oh[0] = op.oh[0]; oh[1] = op.oh[1]; return *this; } /* check if 'name' is a prefix of 's' */ bool lvlhandler::operator==(const string& s) const { return s.COMPARE(0, name.length(), name) == 0; } objhandle JFK::server::new_obstacle(const string& attributes) { objhandle ret = new obstacle(0); ret->fromstring(attributes); return ret; } objhandle JFK::server::new_item(const string& attributes) { objhandle ret = new item(0); ret->fromstring(attributes); return ret; } objhandle JFK::server::new_weapon(const string& attributes) { objhandle ret = new weapon(0); ret->fromstring(attributes); return ret; } bool JFK::server::name_ok(const string& name) { for (size_t i = 0; i < name.length(); i++) { if (!isalnum(name[i]) && name[i] != '_') return false; } return name.size() > 0; }