Make chunk.old_base const

This commit is contained in:
Kp 2015-02-22 01:29:43 +00:00
parent 5ddab4818d
commit 2fa2e17a82
3 changed files with 9 additions and 9 deletions

View file

@ -79,7 +79,7 @@ void vms_vector_swap(vms_vector &v);
*/
struct chunk
{
ubyte *old_base; // where the offset sets off from (relative to beginning of model_data)
const uint8_t *old_base; // where the offset sets off from (relative to beginning of model_data)
ubyte *new_base; // where the base is in the aligned structure
short offset; // how much to add to base to get the address of the offset
short correction; // how much the value of the offset must be shifted for alignment
@ -89,7 +89,7 @@ struct chunk
* finds what chunks the data points to, adds them to the chunk_list,
* and returns the length of the current chunk
*/
int get_chunks(ubyte *data, ubyte *new_data, chunk *list, int *no);
int get_chunks(const uint8_t *data, uint8_t *new_data, chunk *list, int *no);
#endif //def WORDS_NEED_ALIGNMENT
#endif

View file

@ -169,7 +169,7 @@ void swap_polygon_model_data(ubyte *data)
#endif
#ifdef WORDS_NEED_ALIGNMENT
static void add_chunk(ubyte *old_base, ubyte *new_base, int offset,
static void add_chunk(const uint8_t *old_base, uint8_t *new_base, int offset,
chunk *chunk_list, int *no_chunks)
{
Assert(*no_chunks + 1 < MAX_CHUNKS); //increase MAX_CHUNKS if you get this
@ -184,10 +184,10 @@ static void add_chunk(ubyte *old_base, ubyte *new_base, int offset,
* finds what chunks the data points to, adds them to the chunk_list,
* and returns the length of the current chunk
*/
int get_chunks(ubyte *data, ubyte *new_data, chunk *list, int *no)
int get_chunks(const uint8_t *data, uint8_t *new_data, chunk *list, int *no)
{
short n;
ubyte *p = data;
auto p = data;
while (INTEL_SHORT(w(p)) != OP_EOF) {
switch (INTEL_SHORT(w(p))) {

View file

@ -177,13 +177,13 @@ vms_angvec anim_angs[N_ANIM_STATES][MAX_SUBMODELS];
//set the animation angles for this robot. Gun fields of robot info must
//be filled in.
#ifdef WORDS_NEED_ALIGNMENT
static uint8_t *old_dest(const chunk &o) // return where chunk is (in unaligned struct)
static const uint8_t *old_dest(const chunk &o) // return where chunk is (in unaligned struct)
{
return o.old_base + INTEL_SHORT(*((short *)(o.old_base + o.offset)));
return GET_INTEL_SHORT(&o.old_base[o.offset]) + o.old_base;
}
static uint8_t *new_dest(const chunk &o) // return where chunk is (in aligned struct)
{
return o.new_base + INTEL_SHORT(*((short *)(o.old_base + o.offset))) + o.correction;
return GET_INTEL_SHORT(&o.old_base[o.offset]) + o.new_base + o.correction;
}
/*
* find chunk with smallest address
@ -212,7 +212,7 @@ static void align_polygon_model_data(polymodel *pm)
Assert(tmp != NULL);
//start with first chunk (is always aligned!)
auto cur_old = pm->model_data.get();
const uint8_t *cur_old = pm->model_data.get();
auto cur_new = tmp.get();
chunk_len = get_chunks(cur_old, cur_new, ch_list, &no_chunks);
memcpy(cur_new, cur_old, chunk_len);