资源简介
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个文件信息
相关资源
- 黑马最新c、c++全栈培训第24期高清无
- 剑指offer第二版书和代码c++版本.zip
- MFC_Socket_Server.rar
- 31个mfc课程设计有源码和文档.rar
- 妙趣横生的算法C语言实现(1).pdf
- 《C++Primer》第五版中文版.zip
- C语言学习路线图:C语言开发入门及项
- 精通UNIX下C语言编程与项目实践源代码
- c语言程序设计(第二版)谭浩强(完
- 基于C语言的ArcGISENGINE开发基础与技巧
- RSA论文
- C语言大程序游戏大富翁24707
- 三国志游戏源代码C语言版本
- tkdz.cpp
- 科锐C语言系列视频教程.txt
- [郝斌]C语言自学视频教程共180集.txt
- 音乐播放器mfc.doc
- 从C语言转C++简明教程_v5.3.zip
- 坦克大战:(MFC]).zip
- game.cpp
- Demo: c/c++动态库DLL调用,c#等其他语言
- 模拟一个飞机票订票和退票系统
- C++Primer第五版---高清版.zip
- 维吉尼亚密码的简单实现
- bank.cpp
- 从放弃C语言到使用C刷算法的简明教程
- vc6.0上位机教程.docx
- VisualC++范例大全源代码+PDF_百度云盘地
- C++游戏服务器开发从入门到掌握.txt
- C++2017.txt
评论
共有 条评论