00001 //////////////////////////////////////////////////////////////////////////////// 00002 // Scorched3D (c) 2000-2009 00003 // 00004 // This file is part of Scorched3D. 00005 // 00006 // Scorched3D is free software; you can redistribute it and/or modify 00007 // it under the terms of the GNU General Public License as published by 00008 // the Free Software Foundation; either version 2 of the License, or 00009 // (at your option) any later version. 00010 // 00011 // Scorched3D is distributed in the hope that it will be useful, 00012 // but WITHOUT ANY WARRANTY; without even the implied warranty of 00013 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 00014 // GNU General Public License for more details. 00015 // 00016 // You should have received a copy of the GNU General Public License 00017 // along with Scorched3D; if not, write to the Free Software 00018 // Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA 00019 //////////////////////////////////////////////////////////////////////////////// 00020 00021 #include <coms/ComsHaveModFilesMessage.h> 00022 00023 ComsHaveModFilesMessage::ComsHaveModFilesMessage() : 00024 ComsMessage("ComsHaveModFilesMessage") 00025 { 00026 } 00027 00028 ComsHaveModFilesMessage::~ComsHaveModFilesMessage() 00029 { 00030 } 00031 00032 ModIdentifierEntry *ComsHaveModFilesMessage::getFile(const char *name) 00033 { 00034 std::list<ModIdentifierEntry>::iterator itor; 00035 for (itor = files_.begin(); 00036 itor != files_.end(); 00037 itor++) 00038 { 00039 ModIdentifierEntry &entry = *itor; 00040 if (0 == strcmp(entry.fileName.c_str(), name)) 00041 return &entry; 00042 } 00043 00044 return 0; 00045 } 00046 00047 bool ComsHaveModFilesMessage::writeMessage(NetBuffer &buffer) 00048 { 00049 buffer.addToBuffer((int) files_.size()); 00050 std::list<ModIdentifierEntry>::iterator itor; 00051 for (itor = files_.begin(); 00052 itor != files_.end(); 00053 itor++) 00054 { 00055 ModIdentifierEntry &entry = *itor; 00056 buffer.addToBuffer(entry.fileName); 00057 buffer.addToBuffer(entry.length); 00058 buffer.addToBuffer(entry.crc); 00059 } 00060 00061 return true; 00062 } 00063 00064 bool ComsHaveModFilesMessage::readMessage(NetBufferReader &reader) 00065 { 00066 int fileSize = 0; 00067 if (!reader.getFromBuffer(fileSize)) return false; 00068 for (int i=0; i<fileSize; i++) 00069 { 00070 ModIdentifierEntry entry; 00071 reader.getFromBuffer(entry.fileName); 00072 reader.getFromBuffer(entry.length); 00073 reader.getFromBuffer(entry.crc); 00074 files_.push_back(entry); 00075 } 00076 return true; 00077 }
1.5.3