PenUltima Online Forum Index Official Core: 096.7
Official Core: 097 2008-02-26
Donate towards the POL web hosting bill!
 POL Home   FAQ   Search    Memberlist   Usergroups    Register    Profile   Log in to check your private messages   Log in
Another struct problem declaration

 
Post new topic   Reply to topic    PenUltima Online Forum Index -> Bug Reports 097
Display posts from previous:   

Author Message
zandor70



Joined: 10 Feb 2006
Posts: 79
Location: Italy

PostPosted: Wed Apr 25, 2007 10:40 am    Post subject: Another struct problem declaration Reply with quote

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....

Author Message
tekproxy
Distro Developer


Joined: 06 Apr 2006
Posts: 350
Location: Nederland, Texas

PostPosted: Wed Apr 25, 2007 11:42 am    Post subject: Reply with quote

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{ ... });

Author Message
zandor70



Joined: 10 Feb 2006
Posts: 79
Location: Italy

PostPosted: Wed Apr 25, 2007 2:18 pm    Post subject: Reply with quote

wait I try and post results

Author Message
zandor70



Joined: 10 Feb 2006
Posts: 79
Location: Italy

PostPosted: Wed Apr 25, 2007 3:03 pm    Post subject: I have retested all: Reply with quote

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.

Author Message
tekproxy
Distro Developer


Joined: 06 Apr 2006
Posts: 350
Location: Nederland, Texas

PostPosted: Wed Apr 25, 2007 6:43 pm    Post subject: Reply with quote

Thanks for the very thorough testing. I'm sure MuadDib will appreciate it when debugging. Wink

Post new topic   Reply to topic    PenUltima Online Forum Index -> Bug Reports 097 All times are GMT - 4 Hours
Page 1 of 1

 




Powered by phpBB © 2001, 2005 phpBB Group :: Theme & Graphics by GHS & Scott E. Royalty