Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
O
openjazz
Project
Project
Details
Activity
Releases
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
PocketInsanity
openjazz
Commits
1738194a
Commit
1738194a
authored
Sep 26, 2010
by
alistert
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Fixed sprite loading issue. Introduced optional upper limit for loading of shorts.
parent
b3ef0f9a
Changes
8
Show whitespace changes
Inline
Side-by-side
Showing
8 changed files
with
93 additions
and
68 deletions
+93
-68
bonus.cpp
src/bonus/bonus.cpp
+5
-5
file.cpp
src/io/file.cpp
+20
-1
file.h
src/io/file.h
+1
-0
font.cpp
src/io/gfx/font.cpp
+8
-5
demolevel.cpp
src/level/demolevel.cpp
+2
-2
levelload.cpp
src/level/levelload.cpp
+40
-38
main.cpp
src/main.cpp
+2
-2
sceneload.cpp
src/scene/sceneload.cpp
+15
-15
No files found.
src/bonus/bonus.cpp
View file @
1738194a
...
@@ -62,7 +62,7 @@ int Bonus::loadSprites () {
...
@@ -62,7 +62,7 @@ int Bonus::loadSprites () {
file
->
seek
(
2
,
true
);
file
->
seek
(
2
,
true
);
sprites
=
file
->
loadShort
();
sprites
=
file
->
loadShort
(
256
);
spriteSet
=
new
Sprite
[
sprites
];
spriteSet
=
new
Sprite
[
sprites
];
for
(
count
=
0
;
count
<
sprites
;
count
++
)
{
for
(
count
=
0
;
count
<
sprites
;
count
++
)
{
...
@@ -71,8 +71,8 @@ int Bonus::loadSprites () {
...
@@ -71,8 +71,8 @@ int Bonus::loadSprites () {
spriteSet
[
count
].
yOffset
=
0
;
spriteSet
[
count
].
yOffset
=
0
;
// Load dimensions
// Load dimensions
width
=
file
->
loadShort
();
width
=
file
->
loadShort
(
SW
);
height
=
file
->
loadShort
();
height
=
file
->
loadShort
(
SH
);
pixelsLength
=
file
->
loadShort
();
pixelsLength
=
file
->
loadShort
();
maskLength
=
file
->
loadShort
();
maskLength
=
file
->
loadShort
();
...
...
src/io/file.cpp
View file @
1738194a
...
@@ -169,6 +169,25 @@ unsigned short int File::loadShort () {
...
@@ -169,6 +169,25 @@ unsigned short int File::loadShort () {
}
}
unsigned
short
int
File
::
loadShort
(
unsigned
short
int
max
)
{
unsigned
short
int
val
;
val
=
loadShort
();
if
(
val
>
max
)
{
logError
(
"Oversized value in file"
,
filePath
);
return
max
;
}
return
val
;
}
void
File
::
storeShort
(
unsigned
short
int
val
)
{
void
File
::
storeShort
(
unsigned
short
int
val
)
{
fputc
(
val
&
255
,
file
);
fputc
(
val
&
255
,
file
);
...
...
src/io/file.h
View file @
1738194a
...
@@ -50,6 +50,7 @@ class File {
...
@@ -50,6 +50,7 @@ class File {
unsigned
char
loadChar
();
unsigned
char
loadChar
();
void
storeChar
(
unsigned
char
val
);
void
storeChar
(
unsigned
char
val
);
unsigned
short
int
loadShort
();
unsigned
short
int
loadShort
();
unsigned
short
int
loadShort
(
unsigned
short
int
max
);
void
storeShort
(
unsigned
short
int
val
);
void
storeShort
(
unsigned
short
int
val
);
signed
long
int
loadInt
();
signed
long
int
loadInt
();
void
storeInt
(
signed
long
int
val
);
void
storeInt
(
signed
long
int
val
);
...
...
src/io/gfx/font.cpp
View file @
1738194a
...
@@ -82,7 +82,7 @@ Font::Font (const char* fileName) {
...
@@ -82,7 +82,7 @@ Font::Font (const char* fileName) {
size
=
file
->
loadShort
();
size
=
file
->
loadShort
();
if
(
size
)
{
if
(
size
>
4
)
{
pixels
=
file
->
loadRLE
(
size
);
pixels
=
file
->
loadRLE
(
size
);
...
@@ -91,7 +91,10 @@ Font::Font (const char* fileName) {
...
@@ -91,7 +91,10 @@ Font::Font (const char* fileName) {
height
=
pixels
[
2
];
height
=
pixels
[
2
];
height
+=
pixels
[
3
]
<<
8
;
height
+=
pixels
[
3
]
<<
8
;
if
(
size
-
4
>=
width
*
height
)
characters
[
count
]
=
createSurface
(
pixels
+
4
,
width
,
height
);
characters
[
count
]
=
createSurface
(
pixels
+
4
,
width
,
height
);
else
characters
[
count
]
=
createSurface
(
blank
,
3
,
1
);
delete
[]
pixels
;
delete
[]
pixels
;
...
@@ -230,7 +233,7 @@ Font::Font (bool bonus) {
...
@@ -230,7 +233,7 @@ Font::Font (bool bonus) {
fileSize
=
file
->
getSize
();
fileSize
=
file
->
getSize
();
nCharacters
=
file
->
loadShort
();
nCharacters
=
file
->
loadShort
(
256
);
if
(
bonus
)
{
if
(
bonus
)
{
...
@@ -264,8 +267,8 @@ Font::Font (bool bonus) {
...
@@ -264,8 +267,8 @@ Font::Font (bool bonus) {
}
}
width
=
file
->
loadShort
();
width
=
file
->
loadShort
(
SW
);
height
=
file
->
loadShort
();
height
=
file
->
loadShort
(
SH
);
if
(
bonus
)
width
=
(
width
+
3
)
&
~
3
;
if
(
bonus
)
width
=
(
width
+
3
)
&
~
3
;
else
width
<<=
2
;
else
width
<<=
2
;
...
...
src/level/demolevel.cpp
View file @
1738194a
...
@@ -61,8 +61,8 @@ DemoLevel::DemoLevel (const char* fileName) {
...
@@ -61,8 +61,8 @@ DemoLevel::DemoLevel (const char* fileName) {
if
(
file
->
loadShort
()
==
0
)
throw
E_DEMOTYPE
;
if
(
file
->
loadShort
()
==
0
)
throw
E_DEMOTYPE
;
// Level file to load
// Level file to load
lNum
=
file
->
loadShort
();
lNum
=
file
->
loadShort
(
9
);
wNum
=
file
->
loadShort
();
wNum
=
file
->
loadShort
(
999
);
levelFile
=
createFileName
(
F_LEVEL
,
lNum
,
wNum
);
levelFile
=
createFileName
(
F_LEVEL
,
lNum
,
wNum
);
// Difficulty
// Difficulty
...
...
src/level/levelload.cpp
View file @
1738194a
...
@@ -200,6 +200,7 @@ int Level::loadSprites (char * fileName) {
...
@@ -200,6 +200,7 @@ int Level::loadSprites (char * fileName) {
File
*
mainFile
=
NULL
;
File
*
mainFile
=
NULL
;
File
*
specFile
=
NULL
;
File
*
specFile
=
NULL
;
int
count
;
int
count
;
bool
loaded
;
// Open fileName
// Open fileName
...
@@ -214,7 +215,7 @@ int Level::loadSprites (char * fileName) {
...
@@ -214,7 +215,7 @@ int Level::loadSprites (char * fileName) {
}
}
// This function loads all the sprites, not
f
ust those in fileName
// This function loads all the sprites, not
j
ust those in fileName
try
{
try
{
mainFile
=
new
File
(
F_MAINCHAR
,
false
);
mainFile
=
new
File
(
F_MAINCHAR
,
false
);
...
@@ -228,7 +229,7 @@ int Level::loadSprites (char * fileName) {
...
@@ -228,7 +229,7 @@ int Level::loadSprites (char * fileName) {
}
}
sprites
=
specFile
->
loadShort
();
sprites
=
specFile
->
loadShort
(
256
);
// Include space in the sprite set for the blank sprite at the end
// Include space in the sprite set for the blank sprite at the end
spriteSet
=
new
Sprite
[
sprites
+
1
];
spriteSet
=
new
Sprite
[
sprites
+
1
];
...
@@ -249,22 +250,13 @@ int Level::loadSprites (char * fileName) {
...
@@ -249,22 +250,13 @@ int Level::loadSprites (char * fileName) {
// Loop through all the sprites to be loaded
// Loop through all the sprites to be loaded
for
(
count
=
0
;
count
<
sprites
;
count
++
)
{
for
(
count
=
0
;
count
<
sprites
;
count
++
)
{
if
(
specFile
->
loadChar
()
==
0xFF
)
{
loaded
=
false
;
// Go to the next sprite/file indicator
specFile
->
seek
(
1
,
false
);
if
(
mainFile
->
loadChar
()
==
0xFF
)
{
if
(
mainFile
->
loadChar
()
==
0xFF
)
{
// Go to the next sprite/file indicator
// Go to the next sprite/file indicator
mainFile
->
seek
(
1
,
false
);
mainFile
->
seek
(
1
,
false
);
/* Both fileName and mainchar.000 have file indicators, so
create a blank sprite */
spriteSet
[
count
].
clearPixels
();
continue
;
}
else
{
}
else
{
// Return to the start of the sprite
// Return to the start of the sprite
...
@@ -273,21 +265,31 @@ int Level::loadSprites (char * fileName) {
...
@@ -273,21 +265,31 @@ int Level::loadSprites (char * fileName) {
// Load the individual sprite data
// Load the individual sprite data
loadSprite
(
mainFile
,
spriteSet
+
count
);
loadSprite
(
mainFile
,
spriteSet
+
count
);
loaded
=
true
;
}
}
if
(
specFile
->
loadChar
()
==
0xFF
)
{
// Go to the next sprite/file indicator
specFile
->
seek
(
1
,
false
);
}
else
{
}
else
{
// Return to the start of the sprite
// Return to the start of the sprite
specFile
->
seek
(
-
1
,
false
);
specFile
->
seek
(
-
1
,
false
);
// Go to the main file's next sprite/file indicator
mainFile
->
seek
(
2
,
false
);
// Load the individual sprite data
// Load the individual sprite data
loadSprite
(
specFile
,
spriteSet
+
count
);
loadSprite
(
specFile
,
spriteSet
+
count
);
loaded
=
true
;
}
}
/* If both fileName and mainchar.000 have file indicators, create a
blank sprite */
if
(
!
loaded
)
spriteSet
[
count
].
clearPixels
();
// Check if the next sprite exists
// Check if the next sprite exists
// If not, create blank sprites for the remainder
// If not, create blank sprites for the remainder
...
@@ -848,8 +850,8 @@ int Level::load (char* fileName, unsigned char diff, bool checkpoint) {
...
@@ -848,8 +850,8 @@ int Level::load (char* fileName, unsigned char diff, bool checkpoint) {
// The players' initial coordinates
// The players' initial coordinates
startX
=
file
->
loadShort
();
startX
=
file
->
loadShort
(
LW
);
startY
=
file
->
loadShort
()
+
1
;
startY
=
file
->
loadShort
(
LH
)
+
1
;
// Next level
// Next level
...
...
src/main.cpp
View file @
1738194a
...
@@ -211,8 +211,8 @@ int loadMain (int argc, char *argv[]) {
...
@@ -211,8 +211,8 @@ int loadMain (int argc, char *argv[]) {
if
(
file
&&
(
file
->
loadChar
()
==
3
))
{
if
(
file
&&
(
file
->
loadChar
()
==
3
))
{
// Read video settings
// Read video settings
screenW
=
file
->
loadShort
();
screenW
=
file
->
loadShort
(
7680
);
screenH
=
file
->
loadShort
();
screenH
=
file
->
loadShort
(
4800
);
scaleFactor
=
file
->
loadChar
();
scaleFactor
=
file
->
loadChar
();
#ifndef FULLSCREEN_ONLY
#ifndef FULLSCREEN_ONLY
...
...
src/scene/sceneload.cpp
View file @
1738194a
...
@@ -477,11 +477,11 @@ void Scene::loadData (File *f) {
...
@@ -477,11 +477,11 @@ void Scene::loadData (File *f) {
LOG
(
"Data Type"
,
"Image"
);
LOG
(
"Data Type"
,
"Image"
);
LOG
(
"Data Type Image index"
,
loop
);
LOG
(
"Data Type Image index"
,
loop
);
unsigned
short
int
width
=
f
->
loadShort
();
// get width
unsigned
short
int
width
=
f
->
loadShort
(
SW
);
// get width
unsigned
short
int
height
;
unsigned
short
int
height
;
if
(
type
==
3
)
height
=
f
->
loadChar
();
// Get height
if
(
type
==
3
)
height
=
f
->
loadChar
();
// Get height
else
height
=
f
->
loadShort
();
// Get height
else
height
=
f
->
loadShort
(
SH
);
// Get height
f
->
seek
(
-
2
,
false
);
f
->
seek
(
-
2
,
false
);
images
=
new
SceneImage
(
images
);
images
=
new
SceneImage
(
images
);
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment