SCI: cleanup
svn-id: r39371
This commit is contained in:
parent
7854a01f14
commit
364ce5874d
1 changed files with 10 additions and 10 deletions
|
@ -407,7 +407,7 @@ reg_t kStrCpy(EngineState *s, int funct_nr, int argc, reg_t *argv) {
|
||||||
/* Simple heuristic to work around array handling peculiarity in SQ4:
|
/* Simple heuristic to work around array handling peculiarity in SQ4:
|
||||||
It uses StrAt() to read the individual elements, so we must determine
|
It uses StrAt() to read the individual elements, so we must determine
|
||||||
whether a string is really a string or an array. */
|
whether a string is really a string or an array. */
|
||||||
static int is_print_str(char *str) {
|
static int is_print_str(const char *str) {
|
||||||
int printable = 0;
|
int printable = 0;
|
||||||
int len = strlen(str);
|
int len = strlen(str);
|
||||||
|
|
||||||
|
@ -419,7 +419,8 @@ static int is_print_str(char *str) {
|
||||||
// to an unsigned char. Values outside this range (in this
|
// to an unsigned char. Values outside this range (in this
|
||||||
// case, negative values) yield unpredictable results. Refer to:
|
// case, negative values) yield unpredictable results. Refer to:
|
||||||
// http://msdn.microsoft.com/en-us/library/ewx8s4kw.aspx
|
// http://msdn.microsoft.com/en-us/library/ewx8s4kw.aspx
|
||||||
if (isprint((unsigned char)*str)) printable++;
|
if (isprint((byte)*str))
|
||||||
|
printable++;
|
||||||
str++;
|
str++;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -428,20 +429,18 @@ static int is_print_str(char *str) {
|
||||||
|
|
||||||
|
|
||||||
reg_t kStrAt(EngineState *s, int funct_nr, int argc, reg_t *argv) {
|
reg_t kStrAt(EngineState *s, int funct_nr, int argc, reg_t *argv) {
|
||||||
unsigned char *dest = (unsigned char *) kernel_dereference_bulk_pointer(s, argv[0], 0);
|
byte *dest = (byte *)kernel_dereference_bulk_pointer(s, argv[0], 0);
|
||||||
reg_t *dest2;
|
reg_t *dest2;
|
||||||
|
|
||||||
if (!dest) {
|
if (!dest) {
|
||||||
warning("Attempt to StrAt at invalid pointer "PREG"",
|
warning("Attempt to StrAt at invalid pointer "PREG"", PRINT_REG(argv[0]));
|
||||||
PRINT_REG(argv[0]));
|
|
||||||
return NULL_REG;
|
return NULL_REG;
|
||||||
}
|
}
|
||||||
|
|
||||||
if ((argc == 2) &&
|
if ((argc == 2) &&
|
||||||
/* Our pathfinder already works around the issue we're trying to fix */
|
/* Our pathfinder already works around the issue we're trying to fix */
|
||||||
(strcmp(s->seg_manager->getDescription(argv[0]),
|
(strcmp(s->seg_manager->getDescription(argv[0]), AVOIDPATH_DYNMEM_STRING) != 0) &&
|
||||||
AVOIDPATH_DYNMEM_STRING) != 0) &&
|
((strlen((const char*)dest) < 2) || (!is_print_str((const char*)dest))))
|
||||||
((strlen((const char*)dest) < 2) || (!is_print_str((char*)dest))))
|
|
||||||
/* SQ4 array handling detected */
|
/* SQ4 array handling detected */
|
||||||
{
|
{
|
||||||
#ifndef SCUMM_BIG_ENDIAN
|
#ifndef SCUMM_BIG_ENDIAN
|
||||||
|
@ -450,8 +449,9 @@ reg_t kStrAt(EngineState *s, int funct_nr, int argc, reg_t *argv) {
|
||||||
int odd = !(KP_UINT(argv[1]) & 1);
|
int odd = !(KP_UINT(argv[1]) & 1);
|
||||||
#endif
|
#endif
|
||||||
dest2 = ((reg_t *) dest) + (KP_UINT(argv[1]) / 2);
|
dest2 = ((reg_t *) dest) + (KP_UINT(argv[1]) / 2);
|
||||||
dest = ((unsigned char *)(&dest2->offset)) + odd;
|
dest = ((byte *)(&dest2->offset)) + odd;
|
||||||
} else dest += KP_UINT(argv[1]);
|
} else
|
||||||
|
dest += KP_UINT(argv[1]);
|
||||||
|
|
||||||
s->r_acc = make_reg(0, *dest);
|
s->r_acc = make_reg(0, *dest);
|
||||||
|
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue