PenUltima Online

It is currently Sun Oct 12, 2008 4:28 am

All times are UTC - 8 hours




Post new topic Reply to topic  [ 5 posts ] 
Author Message
 Post subject: Another struct problem declaration
PostPosted: Wed Apr 25, 2007 6:40 am 
Offline

Joined: Fri Feb 10, 2006 10:06 am
Posts: 79
Location: Italy
If I use
Code:
var db_realm := { };
db_realm[1] := Struct { "total_loops" := Cint(0), "average_decs" := Cint(0), "delay_ms_after_spawnpoint" := Cint(20) };
print("db_realm[1] "+db_realm[1]);

I obtain as output from print:
db_realm[1] error{ errortext = "Array index out of bounds" }
while If I use

Code:
var db_realm := { };
db_realm[1] := Struct;
db_realm[1] := Struct { "total_loops" := Cint(0), "average_decs" := Cint(0), "delay_ms_after_spawnpoint" := Cint(20) };
print("db_realm[1] "+db_realm[1]);


It's ok....

_________________
Zandor


Top
 Profile  
 
 Post subject:
PostPosted: Wed Apr 25, 2007 7:42 am 
Offline
Distro Developer
User avatar

Joined: Thu Apr 06, 2006 5:11 pm
Posts: 350
Location: Nederland, Texas
If it's a bug Muad will fix it, and you could also try coding it like this:
Code:
CONST DEFAULT_DELAY := 20; // just say "no" to magic numbers
var db_realm := array{struct{ "total_loops" := CInt(0), "average_decs" := CInt(0), "delay_ms_after_spawnpoint" := CInt(DEFAULT_DELAY) }};
// or just use db_realm.append(struct{ ... });


Top
 Profile  
 
 Post subject:
PostPosted: Wed Apr 25, 2007 10:18 am 
Offline

Joined: Fri Feb 10, 2006 10:06 am
Posts: 79
Location: Italy
wait I try and post results

_________________
Zandor


Top
 Profile  
 
 Post subject: I have retested all:
PostPosted: Wed Apr 25, 2007 11:03 am 
Offline

Joined: Fri Feb 10, 2006 10:06 am
Posts: 79
Location: Italy
Code:
  const DEFAULT_DELAY := 20;
  db_realm := array{ Struct{ "total_loops" := CInt(0), "average_decs" := CInt(0), "delay_ms_after_spawnpoint" := CInt(DEFAULT_DELAY) }};
  print("db_realm[1] "+db_realm[1]);

result:
db_realm[1] struct{ average_decs = 0, delay_ms_after_spawnpoint = 20, total_loops = 0 }

Code:
  const DEFAULT_DELAY := 20;
  db_realm := { Struct { "total_loops" := CInt(0), "average_decs" := CInt(0), "delay_ms_after_spawnpoint" := CInt(DEFAULT_DELAY) }};
  print("db_realm[1] "+db_realm[1]);

result:
db_realm[1] struct{ average_decs = 0, delay_ms_after_spawnpoint = 20, total_loops = 0 }

Code:
  const DEFAULT_DELAY := 20;
  db_realm := { };
  db_realm.Append( Struct { "total_loops" := CInt(0), "average_decs" := CInt(0), "delay_ms_after_spawnpoint" := CInt(DEFAULT_DELAY) });
  print("db_realm[1] "+db_realm[1]);

result:
db_realm[1] struct{ average_decs = 0, delay_ms_after_spawnpoint = 20, total_loops = 0 }

Code:
  const DEFAULT_DELAY := 20;
  db_realm := { };
  db_realm[1] := Struct { "total_loops" := CInt(0), "average_decs" := CInt(0), "delay_ms_after_spawnpoint" := CInt(DEFAULT_DELAY) };
  print("db_realm[1] "+db_realm[1]);

result:
db_realm[1] error{ errortext = "Array index out of bounds" }

Code:
  const DEFAULT_DELAY := 20;
  db_realm := { };
  db_realm[1] := Struct;
  db_realm[1] := Struct { "total_loops" := CInt(0), "average_decs" := CInt(0), "delay_ms_after_spawnpoint" := CInt(DEFAULT_DELAY) };
  print("db_realm[1] "+db_realm[1]);

result:
db_realm[1] struct{ average_decs = 0, delay_ms_after_spawnpoint = 20, total_loops = 0 }

Code:
  const DEFAULT_DELAY := 20;
  db_realm := { };
  db_realm[1] := Struct { };
  db_realm[1].+total_loops := CInt(0);
  db_realm[1].+average_decs := CInt(0);
  db_realm[1].+delay_ms_after_spawnpoint := CInt(DEFAULT_DELAY);
  print("db_realm[1] "+db_realm[1]);

result:
db_realm[1] struct{ average_decs = 0, delay_ms_after_spawnpoint = 20, total_loops = 0 }

THe syntax with problem is only when you define and load a struct inside array specifying array index... It seem like a sort of stack problem like the one of function parameter.

_________________
Zandor


Top
 Profile  
 
 Post subject:
PostPosted: Wed Apr 25, 2007 2:43 pm 
Offline
Distro Developer
User avatar

Joined: Thu Apr 06, 2006 5:11 pm
Posts: 350
Location: Nederland, Texas
Thanks for the very thorough testing. I'm sure MuadDib will appreciate it when debugging. ;)


Top
 Profile  
 
Display posts from previous:  Sort by  
Post new topic Reply to topic  [ 5 posts ] 

All times are UTC - 8 hours


Who is online

Users browsing this forum: No registered users and 0 guests


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot post attachments in this forum

Search for:
Jump to:  
Powered by phpBB © 2000, 2002, 2005, 2007 phpBB Group
Style based on FI Subice by phpBBservice.nl