avp_mod is an open source project powered by Assembla

Assembla offers free public and private SVN/Git repositories and project hosting with bug/issue tracking and collaboration tools.

Commitebd360ec63ec976c0...
/c++
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
#include "fragchnk.hpp"
#include <cstring>

RIF_IMPLEMENT_DYNCREATE("FRAGTYPE", Fragment_Type_Chunk)
CHUNK_WITH_CHILDREN_LOADER("FRAGTYPE", Fragment_Type_Chunk)
RIF_IMPLEMENT_DYNCREATE("FRGTYPDC", Fragment_Type_Data_Chunk)

/*
Children for Fragment_Type_Chunk :
Fragment_Type_Data_Chunk        "FRGTYPDC"
Fragment_Type_Shape_Chunk        "FRGTYPSC"
Fragment_Type_Sound_Chunk        "FRGSOUND"
*/

Fragment_Type_Data_Chunk::Fragment_Type_Data_Chunk(Chunk_With_Children* const parent,const char* data,size_t const ) :Chunk(parent,"FRGTYPDC")
{
    int length = strlen(data)+1;
    frag_type_name = data;
    data += (length+3)&~3;

    pad1 = *(int*)data;
    data += 4;
    pad2 = *(int*)data;
    data += 4;
    pad3 = *(int*)data;
    data += 4;
}

void Fragment_Type_Data_Chunk::fill_data_block(char* data_start)
{
    strncpy (data_start, identifier, 8);
    data_start += 8;
    *((int *) data_start) = chunk_size;
    data_start += 4;

    strcpy(data_start, frag_type_name.c_str());
    data_start += (frag_type_name.size() + 4) & ~3;

    *(int*)data_start = pad1;
    data_start += 4;
    *(int*)data_start = pad2;
    data_start += 4;
    *(int*)data_start = pad3;
    data_start += 4;
}

size_t Fragment_Type_Data_Chunk::size_chunk()
{
    chunk_size = 12+12;
    chunk_size += (frag_type_name.size() + 4)&~3;
    return chunk_size;
}

RIF_IMPLEMENT_DYNCREATE("FRGTYPSC", Fragment_Type_Shape_Chunk)

Fragment_Type_Shape_Chunk::Fragment_Type_Shape_Chunk(Chunk_With_Children* parent,const char* _name,int number,ChunkVectorInt _location)
:Chunk(parent,"FRGTYPSC"),num_fragments(number),location(_location),name(_name),pad1(0),pad2(0),pad3(0)
{}

Fragment_Type_Shape_Chunk::Fragment_Type_Shape_Chunk(Chunk_With_Children* const parent,const char* data,size_t const ):Chunk(parent,"FRGTYPSC")
{
    int length = strlen(data)+1;
    name = data;
    data += (length+3)&~3;

    num_fragments = *(int*)data;
    data += 4;

    location = *(ChunkVectorInt*)data;
    data += sizeof(ChunkVectorInt);

    pad1 = *(int*)data;
    data += 4;
    pad2 = *(int*)data;
    data += 4;
    pad3 = *(int*)data;
    data += 4;
}

void Fragment_Type_Shape_Chunk::fill_data_block(char* data_start)
{
    strncpy (data_start, identifier, 8);
    data_start += 8;
    *((int *) data_start) = chunk_size;
    data_start += 4;

    strcpy(data_start,name.c_str());
    data_start += (name.size() + 4)&~3;

    *(int*)data_start = num_fragments;
    data_start += 4;

    *(ChunkVectorInt*)data_start = location;
    data_start += sizeof(ChunkVectorInt);

    *(int*)data_start = pad1;
    data_start += 4;
    *(int*)data_start = pad2;
    data_start += 4;
    *(int*)data_start = pad3;
    data_start += 4;
}

size_t Fragment_Type_Shape_Chunk::size_chunk()
{
    chunk_size = 12+16+sizeof(ChunkVectorInt);
    chunk_size += (name.size() + 4)&~3;

return chunk_size;
}

RIF_IMPLEMENT_DYNCREATE("FRGSOUND",Fragment_Type_Sound_Chunk)

Fragment_Type_Sound_Chunk::Fragment_Type_Sound_Chunk(Chunk_With_Children* parent):Chunk(parent,"FRGSOUND")
{
    inner_range = 5000;
    outer_range = 40000;
    max_volume = 127;
    pitch = 0;
    pad = 0;
}

Fragment_Type_Sound_Chunk::Fragment_Type_Sound_Chunk(Chunk_With_Children* const parent,const char* data,size_t const ) :Chunk(parent,"FRGSOUND")
{
    inner_range = *(uint32_t *)data;
    data += 4;
    outer_range = *(uint32_t *)data;
    data += 4;

    max_volume = *(int*)data;
    data += 4;
    pitch = *(int*)data;
    data += 4;
    pad = *(int*)data;
    data += 4;

    wav_name = data;
}

void Fragment_Type_Sound_Chunk::fill_data_block(char* data_start)
{
    strncpy (data_start, identifier, 8);
    data_start += 8;
    *((int *) data_start) = chunk_size;
    data_start += 4;

    *(uint32_t *)data_start = inner_range;
    data_start += 4;
    *(uint32_t *)data_start = outer_range;
    data_start += 4;

    *(int*)data_start = max_volume;
    data_start += 4;
    *(int*)data_start = pitch;
    data_start += 4;
    *(int*)data_start = pad;
    data_start += 4;

    strcpy(data_start, wav_name.c_str());
}

size_t Fragment_Type_Sound_Chunk::size_chunk()
{
    chunk_size = 12+20;
    chunk_size += (wav_name.size() + 4) & ~3;

return chunk_size;
}
Ajax-loader Loading, please wait...