UCC Errors/Issues/Comments/etc.
Forum rules
NOTICE: This forum is archived as read only.
Please use the Github Discussions at https://github.com/exult/exult/discussions
NOTICE: This forum is archived as read only.
Please use the Github Discussions at https://github.com/exult/exult/discussions
Re: UCC Errors/Issues/Comments/etc.
Can you give a code example of minimal length that shows the problem?
-
- Posts: 1241
- Joined: Thu May 14, 2020 1:34 pm
Re: UCC Errors/Issues/Comments/etc.
It's illustrated quite well in the TFL snapshot I have thusfar.
http://www.lfs.lfhost.com/tfl_forum/viewtopic.php?t=21
Just teleport to Spektran, the go north, on an island is a NPC, Chahiero. ask job, and he will have 'karma' and the debug choice, 'write karma'
Try write karma - you will see that the write will work, and you can increment karma upwards ... *but* then change the subject, and the static var returns to its default value of 0.
The well-documented code is in the /patch/src/ directory of the patch. Specifically,
/patch/src/karma/karma.uc
/patch/src/karma/related_functions/karma_functions.uc
/patch/src/npcs/related_functions/chahiero_dialog.uc
A clean 'fix' of sorts would be to have a game variables thing just as we have game flags, which would also solve my problem of how to save a karma with a savegame.
~ Wizardry Dragon
http://www.lfs.lfhost.com/tfl_forum/viewtopic.php?t=21
Just teleport to Spektran, the go north, on an island is a NPC, Chahiero. ask job, and he will have 'karma' and the debug choice, 'write karma'
Try write karma - you will see that the write will work, and you can increment karma upwards ... *but* then change the subject, and the static var returns to its default value of 0.
The well-documented code is in the /patch/src/ directory of the patch. Specifically,
/patch/src/karma/karma.uc
/patch/src/karma/related_functions/karma_functions.uc
/patch/src/npcs/related_functions/chahiero_dialog.uc
A clean 'fix' of sorts would be to have a game variables thing just as we have game flags, which would also solve my problem of how to save a karma with a savegame.
~ Wizardry Dragon
Cheers, Wizardry Dragon
Lead Designer, Ultima VII: The Feudal Lands
www.thefeudallands.ca
Lead Designer, Ultima VII: The Feudal Lands
www.thefeudallands.ca
Re: UCC Errors/Issues/Comments/etc.
Not exactly "of minimal length", is it?
In any case, looks like global statics are totally broken. I fixed them, but can't commit it because the CVS server appears to be down. (I'll commit the fix as soon as possible.)
Incidentally, your comment
"used to have static vars in here but apparently they have to be in usecode.uc"
is wrong. They can be in karma.uc as long as all .uc files that use those variables are included _after_ their definition in karma.uc.
Specifically, that means the inclusion of karma_functions.uc has to be below the definition of the static karma vars.
In any case, looks like global statics are totally broken. I fixed them, but can't commit it because the CVS server appears to be down. (I'll commit the fix as soon as possible.)
Incidentally, your comment
"used to have static vars in here but apparently they have to be in usecode.uc"
is wrong. They can be in karma.uc as long as all .uc files that use those variables are included _after_ their definition in karma.uc.
Specifically, that means the inclusion of karma_functions.uc has to be below the definition of the static karma vars.
-
- Posts: 1241
- Joined: Thu May 14, 2020 1:34 pm
Re: UCC Errors/Issues/Comments/etc.
I speak only from my experience in what compiled and what didnt WJP, not what *should* work ^_~
Either way, Marzo has got me a good-sounding workaround that I'm trying, but if you could fix static vars that would be very helpful ^_^
As to the 'minimal length' thing - you shouldve seen how it was before I shaved it down and optimized it. My first code run is almost alway at least twice as long as the finished product ^_~
~ Wizardry Dragon
Either way, Marzo has got me a good-sounding workaround that I'm trying, but if you could fix static vars that would be very helpful ^_^
As to the 'minimal length' thing - you shouldve seen how it was before I shaved it down and optimized it. My first code run is almost alway at least twice as long as the finished product ^_~
~ Wizardry Dragon
Cheers, Wizardry Dragon
Lead Designer, Ultima VII: The Feudal Lands
www.thefeudallands.ca
Lead Designer, Ultima VII: The Feudal Lands
www.thefeudallands.ca
Re: UCC Errors/Issues/Comments/etc.
> I speak only from my experience in what compiled and what didnt WJP, not what *should* work ^_~
ucc didn't complain when moving the karma vars to the top of karma.uc...
ucc didn't complain when moving the karma vars to the top of karma.uc...
-
- Posts: 1241
- Joined: Thu May 14, 2020 1:34 pm
Re: UCC Errors/Issues/Comments/etc.
Huh, it did for me. But a lot of things seem to go wrong for me that dont for others. UCC hates me ;_;
Didn't get any success with a workaround yet, so no working karma system. Grr ... the groundwork of this *should* be easy x_x
~ Wizardry Dragon
Didn't get any success with a workaround yet, so no working karma system. Grr ... the groundwork of this *should* be easy x_x
~ Wizardry Dragon
Cheers, Wizardry Dragon
Lead Designer, Ultima VII: The Feudal Lands
www.thefeudallands.ca
Lead Designer, Ultima VII: The Feudal Lands
www.thefeudallands.ca
Re: UCC Errors/Issues/Comments/etc.
//The heart of the karma system:
#include "karma/related_functions/karma_functions.uc";
//Overall good/evil:
static var karma;
---
You need to declare the static var(s) above the include there for it to be recognized inside karma_functions.uc.
#include "karma/related_functions/karma_functions.uc";
//Overall good/evil:
static var karma;
---
You need to declare the static var(s) above the include there for it to be recognized inside karma_functions.uc.
-
- Posts: 1241
- Joined: Thu May 14, 2020 1:34 pm
Re: UCC Errors/Issues/Comments/etc.
Eh, well I worked around it using NPC props (Marzo's suggestion), so all is good in the world.
The latest snapshot of TFL has a fully-functional (though not implemented in much depth) karma system. ^_^
http://www.lfs.lfhost.com/tfl_forum/vie ... ?p=152#152
~ Wizardry Dragon
The latest snapshot of TFL has a fully-functional (though not implemented in much depth) karma system. ^_^
http://www.lfs.lfhost.com/tfl_forum/vie ... ?p=152#152
~ Wizardry Dragon
Cheers, Wizardry Dragon
Lead Designer, Ultima VII: The Feudal Lands
www.thefeudallands.ca
Lead Designer, Ultima VII: The Feudal Lands
www.thefeudallands.ca
Re: UCC Errors/Issues/Comments/etc.
Did static vars get broken recently, or have they been bad for a while. I seem to remember problems when Marzo first tried using them, but thought those were fixed.
-
- Posts: 1241
- Joined: Thu May 14, 2020 1:34 pm
Re: UCC Errors/Issues/Comments/etc.
Im unsure, I just know they sure didn't work when I tried them, and given that Marzo suggested the workaround, I think he may have had to use a similar workaround.
I can't speak for Marzo, though.
~ Wizardry Dragon
I can't speak for Marzo, though.
~ Wizardry Dragon
Cheers, Wizardry Dragon
Lead Designer, Ultima VII: The Feudal Lands
www.thefeudallands.ca
Lead Designer, Ultima VII: The Feudal Lands
www.thefeudallands.ca
Re: UCC Errors/Issues/Comments/etc.
Not sure. With the cvs server down I can't run cvs annotate to easily check.
The problem was that it was casting a sint16 into a uint16 into sint32, thereby losing the sign info. Since global statics depended on this offset being negative, they weren't working. (It was instead accessing local static number 65000+)
The problem was that it was casting a sint16 into a uint16 into sint32, thereby losing the sign info. Since global statics depended on this offset being negative, they weren't working. (It was instead accessing local static number 65000+)
Re: UCC Errors/Issues/Comments/etc.
The thing is that I never really tried using global statics (as Wizardry is), so I can't tell for sure for how long they have been broken. Normal (local) statics are working fine.
------
Marzo Sette Torres Junior
aka Geometrodynamic Dragon
[url=http://www.catb.org/~esr/faqs/smart-questions.html]How To Ask Questions The Smart Way[/url]
Marzo Sette Torres Junior
aka Geometrodynamic Dragon
[url=http://www.catb.org/~esr/faqs/smart-questions.html]How To Ask Questions The Smart Way[/url]
-
- Posts: 1241
- Joined: Thu May 14, 2020 1:34 pm
Re: UCC Errors/Issues/Comments/etc.
As I am no longer, Marzo ^_~
Im using NPC props now, and it works, saves with savegames, and everything.
~ Wizardry Dragon
Im using NPC props now, and it works, saves with savegames, and everything.
~ Wizardry Dragon
Cheers, Wizardry Dragon
Lead Designer, Ultima VII: The Feudal Lands
www.thefeudallands.ca
Lead Designer, Ultima VII: The Feudal Lands
www.thefeudallands.ca
Re: UCC Errors/Issues/Comments/etc.
Sorry to bring up a dead thread, but I does anyone know if the global statics work now?
I can declare it fine, such as
static var test;
but I can't seem to assign any value to it, but its a large possibility that I simply don't know how to assign values to it correctly so the compile is failing (I'm doing test = 1; and it's coming up with "expecting `'('' ".
I can declare it fine, such as
static var test;
but I can't seem to assign any value to it, but its a large possibility that I simply don't know how to assign values to it correctly so the compile is failing (I'm doing test = 1; and it's coming up with "expecting `'('' ".
Re: UCC Errors/Issues/Comments/etc.
You should be able to assign to it inside a function. Is it possible there's something else named 'test'?
Re: UCC Errors/Issues/Comments/etc.
Stupid mistake on my part which was causing the compiling error (and for the sake of avoiding any potential duplicates I renamed it to statictesting)
However, while I do not get the compiling error anymore, the value does not seem to be assigned to it, though I suspect this is due to my lack of understanding on how to actually assign a value to it.
I have my static var statictesting declared at the top of my usecode.uc which has all my #include's etc, in it.
I made a NPC that when I say a certain phrase I have:
statictesting = 50;
AVATAR.say("Statictesting value is ", statictesting);
This always returns no value on the statictesting, unless of course I do var statictesting = 50; which then works, but it is only local.
Looking up c# tutorials on how to do global variables I believe I understand the concept, but I can't actually get a working version that will compile under ucc.
Is what I'm doing correct, or is it completely off for this?
However, while I do not get the compiling error anymore, the value does not seem to be assigned to it, though I suspect this is due to my lack of understanding on how to actually assign a value to it.
I have my static var statictesting declared at the top of my usecode.uc which has all my #include's etc, in it.
I made a NPC that when I say a certain phrase I have:
statictesting = 50;
AVATAR.say("Statictesting value is ", statictesting);
This always returns no value on the statictesting, unless of course I do var statictesting = 50; which then works, but it is only local.
Looking up c# tutorials on how to do global variables I believe I understand the concept, but I can't actually get a working version that will compile under ucc.
Is what I'm doing correct, or is it completely off for this?
Re: UCC Errors/Issues/Comments/etc.
Try this instead:
As a suggestion: unless you need the static var to be accessible from multiple different functions, it is better (in all possible ways) to declare the static var from inside the function it is used.
Code: Select all
statictesting = 50;
AVATAR.say("Statictesting value is " + statictesting);
------
Marzo Sette Torres Junior
aka Geometrodynamic Dragon
[url=http://www.catb.org/~esr/faqs/smart-questions.html]How To Ask Questions The Smart Way[/url]
Marzo Sette Torres Junior
aka Geometrodynamic Dragon
[url=http://www.catb.org/~esr/faqs/smart-questions.html]How To Ask Questions The Smart Way[/url]
Re: UCC Errors/Issues/Comments/etc.
That got it working, thanks.
Thanks for the suggestion as well.
Thanks for the suggestion as well.