Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 7014769
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 27, 20262026-05-27T22:33:52+00:00 2026-05-27T22:33:52+00:00

Usually, entities and components or other parts of the game code in data-driven design

  • 0

Usually, entities and components or other parts of the game code in data-driven design will have names that get checked if you want to find out which object you’re dealing with exactly.

void Player::Interact(Entity *myEntity)
{
    if(myEntity->isNearEnough(this) && myEntity->GetFamilyName() == "guard")
    {
       static_cast<Guard*>(myEntity)->Say("No mention of arrows and knees here");
    }
}

If you ignore the possibility that this might be premature optimization, it’s pretty clear that looking up entities would be a lot faster if their “name” was a simple 32 bit value instead of an actual string.

Computing hashes out of the string names is one possible option. I haven’t actually tried it, but with a range of 32bit and a good hashing function the risk of collision should be minimal.

The question is this: Obviously we need some way to convert in-code (or in some kind of external file) string-names to those integers, since the person working on these named objects will still want to refer to the object as “guard” instead of “0x2315f21a”.

Assuming we’re using C++ and want to replace all strings that appear in the code, can this even be achieved with language-built in features or do we have to build an external tool that manually looks through all files and exchanges the values?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-27T22:33:53+00:00Added an answer on May 27, 2026 at 10:33 pm

    Jason Gregory wrote this on his book :

    At Naughty Dog, we used a variant of the CRC-32 algorithm to hash our strings, and we didn’t encounter a single collision in over two years of development on Uncharted: Drake’s Fortune.

    So you may want to look into that.

    And about the build step you mentioned, he also talked about it. They basically encapsulate the strings that need to be hashed in something like:

    _ID("string literal")
    

    And use an external tool at build time to hash all the occurrences. This way you avoid any runtime costs.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have two entities that usually have one-to-many relationship, but in rare cases should
I have a Core Data model with 2 entities: Game and ScoreTable. A Game
I have a service with some entities that I would like to expose in
Usually when defining a DAO, you would have a setter for the datasource on
Usually I come across situations where I have to swallow an exception thrown by
Let's say you have a Classroom entity with an collection of Student entities. What
I'm struggling with a (usually simple to deal with) problem. I have a database
In my Rails app I have a fairly standard has_many relationship between two entities.
I want to get the last entry into the database, I usually used SCOPE_IDENTITY()
I've got a repository using LINQ for modelling the data that has a whole

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.