資源簡介
C++多人2D坦克大戰源碼.rar
代碼片段和文件信息
/*?libclunk?-?realtime?2d/3d?sound?render?library
?*?Copyright?(C)?2007-2008?Netive?Media?Group
?*
?*?This?library?is?free?software;?you?can?redistribute?it?and/or
?*?modify?it?under?the?terms?of?the?GNU?Lesser?General?Public
?*?License?as?published?by?the?Free?Software?Foundation;?either
?*?version?2.1?of?the?License?or?(at?your?option)?any?later?version.
?*?This?library?is?distributed?in?the?hope?that?it?will?be?useful
?*?but?WITHOUT?ANY?WARRANTY;?without?even?the?implied?warranty?of
?*?MERCHANTABILITY?or?FITNESS?FOR?A?PARTICULAR?PURPOSE.??See?the?GNU
?*?Lesser?General?Public?License?for?more?details.
?*?
?*?You?should?have?received?a?copy?of?the?GNU?Lesser?General?Public
?*?License?along?with?this?library;?if?not?write?to?the?Free?Software
?*?Foundation?Inc.?51?Franklin?Street?Fifth?Floor?Boston?MA?02110-1301?USA
*/
#include?“buffer.h“
#include?
#include?
#include?“mrt/ioexception.h“
#include?
#include?“mrt/fmt.h“
using?namespace?clunk;
void?Buffer::fill(const?int?b)?{
if?(ptr?==?NULL)?
return;
memset(ptr?b?size);
}
const?Buffer&?Buffer::operator=(const?Buffer&?c)?{
if?(this?==?&c)?
return?*this;?//?same?object
if?(c.ptr?==?NULL)?{
free();
return?*this;
}
assert(c.size?>?0);
void?*p?=?realloc(ptr?c.size);
if?(p?==?NULL)?
throw_io((“realloc?(%p?%u)“?ptr?(unsigned)c.size));
ptr?=?p;
size?=?c.size;
memcpy(ptr?c.ptr?c.size);
return?*this;
}
void?Buffer::set_size(size_t?s)?{
if?(s?==?size)
return;
if?(s?==?0)?{
free();
return;
}
void?*?x?=?realloc(ptr?s);
if?(x?==?NULL)?
throw_io((“realloc?(%p?%u)“?ptr?(unsigned)s));
ptr?=?x;
size?=?s;
}
void?Buffer::set_data(const?void?*p?const?size_t?s)?{
if?(p?==?NULL?||?s?==?0)
throw_ex((“calling?set_data(%p?%u)?is?invalid“?p?(unsigned)s));
void?*x?=?realloc(ptr?s);
if?(x?==?NULL)?
throw_io((“realloc?(%p?%d)“?ptr?(unsigned)s));
ptr?=?x;
memcpy(ptr?p?s);
size?=?s;
}
void?Buffer::set_data(void?*p?const?size_t?s?const?bool?own)?{
if?(p?==?NULL?||?s?==?0)?
throw_ex((“calling?set_data(%p?%u?%s)?is?invalid“?p?(unsigned)s?own?“true“:“false“));
if?(own)?{
free();
ptr?=?p;
size?=?s;
}?else?{
void?*x?=?realloc(ptr?s);
if?(x?==?NULL)?
throw_io((“realloc(%p?%d)“?ptr?(unsigned)s));
ptr?=?x;
size?=?s;
memcpy(ptr?p?s);
}
}
void?Buffer::append(const?Buffer?&other)?{
size_t?s1?=?size?s2?=?other.get_size();
if?(s2?==?0)
return;
set_size(s1?+?s2);
memcpy((char?*)?ptr?+?s1?other.ptr?s2);
}
void?Buffer::append(const?void?*data?const?size_t?data_size)?{
if?(data_size?==?0)
return;
size_t?s?=?size;
set_size(s?+?data_size);
memcpy((char?*)?ptr?+?s?data?data_size);
}
void*?Buffer::reserve(const?int?more)?{
set_size(size?+?more);
return?ptr;
}
void?Buffer::free()?{
if?(ptr?!=?NULL)?{
::free(ptr);
ptr?=?NULL;
size?=?0;
}
}
const?std::string?Buffer::dump()?const?{
if?(ptr?==?NULL)
return?“empty?memory?buffer“;
assert(ptr?!=?0);
std::strin
?屬性????????????大小?????日期????時間???名稱
-----------?---------??----------?-----??----
?????文件??????????7??2008-09-04?12:07??C++多人2D坦克大戰源碼\tanke\.svnversion
?????文件??????22766??2008-09-01?20:24??C++多人2D坦克大戰源碼\tanke\ChangeLog
?????文件???????3848??2008-08-04?18:55??C++多人2D坦克大戰源碼\tanke\clunk\buffer.cpp
?????文件???????1905??2008-08-04?18:55??C++多人2D坦克大戰源碼\tanke\clunk\buffer.h
?????文件????????996??2008-06-07?19:58??C++多人2D坦克大戰源碼\tanke\clunk\clunk.h
?????文件??????14444??2008-08-04?18:55??C++多人2D坦克大戰源碼\tanke\clunk\context.cpp
?????文件???????4396??2008-08-04?18:55??C++多人2D坦克大戰源碼\tanke\clunk\context.h
?????文件??????51995??2008-06-07?20:20??C++多人2D坦克大戰源碼\tanke\clunk\Doxyfile
?????文件????????879??2008-08-04?18:55??C++多人2D坦克大戰源碼\tanke\clunk\export_clunk.h
?????文件????8375484??2008-03-12?18:38??C++多人2D坦克大戰源碼\tanke\clunk\kemar.c
?????文件???????1247??2008-03-14?15:44??C++多人2D坦克大戰源碼\tanke\clunk\kemar.h
?????文件??????11972??2008-03-12?18:32??C++多人2D坦克大戰源碼\tanke\clunk\kiss\kiss_fft.c
?????文件???????3105??2008-08-05?15:53??C++多人2D坦克大戰源碼\tanke\clunk\kiss\kiss_fft.h
?????文件???????5931??2008-03-12?18:32??C++多人2D坦克大戰源碼\tanke\clunk\kiss\kiss_fftr.c
?????文件????????858??2008-03-12?18:32??C++多人2D坦克大戰源碼\tanke\clunk\kiss\kiss_fftr.h
?????文件???????5260??2008-03-12?18:32??C++多人2D坦克大戰源碼\tanke\clunk\kiss\_kiss_fft_guts.h
?????文件???????1290??2008-06-07?19:58??C++多人2D坦克大戰源碼\tanke\clunk\locker.h
?????文件???????3091??2008-06-07?18:35??C++多人2D坦克大戰源碼\tanke\clunk\ob
?????文件???????3594??2008-06-07?18:35??C++多人2D坦克大戰源碼\tanke\clunk\ob
?????文件???????1993??2008-08-04?18:55??C++多人2D坦克大戰源碼\tanke\clunk\sample.cpp
?????文件???????1801??2008-08-04?18:55??C++多人2D坦克大戰源碼\tanke\clunk\sample.h
?????文件????????973??2008-08-04?18:55??C++多人2D坦克大戰源碼\tanke\clunk\SConsc
?????文件???????1044??2008-06-08?17:02??C++多人2D坦克大戰源碼\tanke\clunk\sdl_ex.cpp
?????文件???????1105??2008-06-07?18:35??C++多人2D坦克大戰源碼\tanke\clunk\sdl_ex.h
?????文件??????11561??2008-08-19?01:28??C++多人2D坦克大戰源碼\tanke\clunk\source.cpp
?????文件???????3041??2008-08-19?00:04??C++多人2D坦克大戰源碼\tanke\clunk\source.h
?????文件????????969??2008-06-07?18:35??C++多人2D坦克大戰源碼\tanke\clunk\stream.cpp
?????文件???????2008??2008-08-04?18:55??C++多人2D坦克大戰源碼\tanke\clunk\stream.h
?????文件???????6687??2008-06-07?19:58??C++多人2D坦克大戰源碼\tanke\clunk\v3.h
?????文件??????13611??2008-09-02?19:43??C++多人2D坦克大戰源碼\tanke\data\editor.xm
............此處省略966個文件信息
評論
共有 條評論