• Announcements

    • khawk

      Download the Game Design and Indie Game Marketing Freebook   07/19/17

      GameDev.net and CRC Press have teamed up to bring a free ebook of content curated from top titles published by CRC Press. The freebook, Practices of Game Design & Indie Game Marketing, includes chapters from The Art of Game Design: A Book of Lenses, A Practical Guide to Indie Game Marketing, and An Architectural Approach to Level Design. The GameDev.net FreeBook is relevant to game designers, developers, and those interested in learning more about the challenges in game development. We know game development can be a tough discipline and business, so we picked several chapters from CRC Press titles that we thought would be of interest to you, the GameDev.net audience, in your journey to design, develop, and market your next game. The free ebook is available through CRC Press by clicking here. The Curated Books The Art of Game Design: A Book of Lenses, Second Edition, by Jesse Schell Presents 100+ sets of questions, or different lenses, for viewing a game’s design, encompassing diverse fields such as psychology, architecture, music, film, software engineering, theme park design, mathematics, anthropology, and more. Written by one of the world's top game designers, this book describes the deepest and most fundamental principles of game design, demonstrating how tactics used in board, card, and athletic games also work in video games. It provides practical instruction on creating world-class games that will be played again and again. View it here. A Practical Guide to Indie Game Marketing, by Joel Dreskin Marketing is an essential but too frequently overlooked or minimized component of the release plan for indie games. A Practical Guide to Indie Game Marketing provides you with the tools needed to build visibility and sell your indie games. With special focus on those developers with small budgets and limited staff and resources, this book is packed with tangible recommendations and techniques that you can put to use immediately. As a seasoned professional of the indie game arena, author Joel Dreskin gives you insight into practical, real-world experiences of marketing numerous successful games and also provides stories of the failures. View it here. An Architectural Approach to Level Design This is one of the first books to integrate architectural and spatial design theory with the field of level design. The book presents architectural techniques and theories for level designers to use in their own work. It connects architecture and level design in different ways that address the practical elements of how designers construct space and the experiential elements of how and why humans interact with this space. Throughout the text, readers learn skills for spatial layout, evoking emotion through gamespaces, and creating better levels through architectural theory. View it here. Learn more and download the ebook by clicking here. Did you know? GameDev.net and CRC Press also recently teamed up to bring GDNet+ Members up to a 20% discount on all CRC Press books. Learn more about this and other benefits here.
Sign in to follow this  
Followers 0
Marcus L

Problem with array of handles

7 posts in this topic

Hi again!

It seems I've encountered a bug in the newest version of the scriptarray add-on (tested rev1771 also). AngelScript yields the following error:

 

 

'Type 'A' does not have a matching opEquals or opCmp method'

... When i run something like this:
 

class A {}

array<A@> list;

void main() {
    A a;
    list.insertLast(@a);
    int idx = list.find(@a); // ERROR
}

I'm sure there is an easy fix for this, but knowing me I'll probably take ages to figure it out, so for the time being I think I'll just revert back to an older version of the add-on tongue.png.
 

Edited by Marcus L
0

Share this post


Link to post
Share on other sites

It's not a bug. The array currently use the opEquals or opCmp of the object when using find (or sort), where it previously did a direct compare of the pointers. This was changed recently as otherwise there was no way doing a find or sort by value in arrays of handles. 

 

But I see your point. I'll probably need to add an additional method for doing an exact match which compares the pointers, so for arrays of object handles it will have both options. 

 

This is similar to the difference between the operators == and is. The former does a value comparison, and the latter does an address comparison.

0

Share this post


Link to post
Share on other sites

Oh, i guess that does make sense smile.png
 

 

This is similar to the difference between the operators == and is.The former does a value comparison, and the latter does an address comparison.

Wait. So does this mean that something like @objectA == @objectB will perform a value comparison? Or is when you omit the '@'s that a value comparison will be done?

I have a suggestion on how the original problem can be solved, but as i don't know the inner workings of AngelScript, i don't know if this is too difficult to pull off. However, what i thought could work, is when the script writer wrote something like "list.find(@a)", then AS would interpret this as look for the handle of 'a' in the list, while if the script writer wrote "list.find(a)", then it would be interpreted as look for the value of 'a' in the list (using opCmp).

Anyways, thanks for clearing that up smile.png !

Edited by Marcus L
0

Share this post


Link to post
Share on other sites

By using the @ symbol you explicitly say the expression should operate on the address, thus @objectA == @objectB is identical to objectA is objectB, and perform a comparison of the handles. objectA == objectB does a comparison of the values using opEquals (or opCmp if the former doesn't exist).

 

 

Since the find method of the array of handles takes as parameter a handle, the compiler will implictly convert any expression to a handle even if the script writer doesn't use the @ symbol.

 

object @a;

array<object@> list;

list.find(@a);   // explicitly pass the handle

list.find(a);    // implicitly pass the handle

 

I'm thinking about resolving this by adding an optional boolean argument where the script can specifically mention if the comparison should be done by value or by address. It will then be something like this:

 

array<int> a;

a.find(42);         // By default value comparison is performed

array<object@> b;

b.find(obj, true);  // Explciticly inform search by address comparison

b.find(obj, false); // Explictly inform search by value comparison

 

 

But I'll need to give this some more thought before implementing it.

0

Share this post


Link to post
Share on other sites

I'll just chime in here and say that it isn't especially obvious what the bool parameter in find() would do. It might be clearer to name it something like findByRef(). Just my two cents. smile.png

Edited by Jake Albano
0

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!


Register a new account

Sign in

Already have an account? Sign in here.


Sign In Now
Sign in to follow this  
Followers 0