aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorludwig <ludwig@edf5b092-35ff-0310-97b2-ce42778d08ea>2005-11-01 19:44:36 +0000
committerludwig <ludwig@edf5b092-35ff-0310-97b2-ce42778d08ea>2005-11-01 19:44:36 +0000
commitf128ee5f91cb8460658ec14ac39daab6f98b6bc4 (patch)
tree43d7883f18f69c3cc2d1132f165b2c1b1ba419bf
parent24b3361cea084b9038c0f67bf423cd429877fd85 (diff)
downloadioquake3-aero-f128ee5f91cb8460658ec14ac39daab6f98b6bc4.tar.gz
ioquake3-aero-f128ee5f91cb8460658ec14ac39daab6f98b6bc4.zip
use memcpy to fix use of misaligned data
git-svn-id: svn://svn.icculus.org/quake3/trunk@206 edf5b092-35ff-0310-97b2-ce42778d08ea
-rw-r--r--code/renderer/tr_image.c39
1 files changed, 21 insertions, 18 deletions
diff --git a/code/renderer/tr_image.c b/code/renderer/tr_image.c
index 1422a09..8967e02 100644
--- a/code/renderer/tr_image.c
+++ b/code/renderer/tr_image.c
@@ -1148,25 +1148,28 @@ static void LoadTGA ( const char *name, byte **pic, int *width, int *height)
buf_p = buffer;
- targa_header.id_length = *buf_p++;
- targa_header.colormap_type = *buf_p++;
- targa_header.image_type = *buf_p++;
+ targa_header.id_length = buf_p[0];
+ targa_header.colormap_type = buf_p[1];
+ targa_header.image_type = buf_p[2];
- targa_header.colormap_index = LittleShort ( *(short *)buf_p );
- buf_p += 2;
- targa_header.colormap_length = LittleShort ( *(short *)buf_p );
- buf_p += 2;
- targa_header.colormap_size = *buf_p++;
- targa_header.x_origin = LittleShort ( *(short *)buf_p );
- buf_p += 2;
- targa_header.y_origin = LittleShort ( *(short *)buf_p );
- buf_p += 2;
- targa_header.width = LittleShort ( *(short *)buf_p );
- buf_p += 2;
- targa_header.height = LittleShort ( *(short *)buf_p );
- buf_p += 2;
- targa_header.pixel_size = *buf_p++;
- targa_header.attributes = *buf_p++;
+ memcpy(&targa_header.colormap_index, &buf_p[3], 2);
+ memcpy(&targa_header.colormap_length, &buf_p[5], 2);
+ targa_header.colormap_size = buf_p[8];
+ memcpy(&targa_header.x_origin, &buf_p[9], 2);
+ memcpy(&targa_header.y_origin, &buf_p[11], 2);
+ memcpy(&targa_header.width, &buf_p[13], 2);
+ memcpy(&targa_header.height, &buf_p[15], 2);
+ targa_header.pixel_size = buf_p[16];
+ targa_header.attributes = buf_p[17];
+
+ targa_header.colormap_index = LittleShort(targa_header.colormap_index);
+ targa_header.colormap_length = LittleShort(targa_header.colormap_length);
+ targa_header.x_origin = LittleShort(targa_header.x_origin);
+ targa_header.y_origin = LittleShort(targa_header.y_origin);
+ targa_header.width = LittleShort(targa_header.width);
+ targa_header.height = LittleShort(targa_header.height);
+
+ buf_p += 18;
if (targa_header.image_type!=2
&& targa_header.image_type!=10