x

Search in
Sort by:

Question Status:

Search help

  • Simple searches use one or more words. Separate the words with spaces (cat dog) to search cat,dog or both. Separate the words with plus signs (cat +dog) to search for items that may contain cat but must contain dog.
  • You can further refine your search on the search results page, where you can search by keywords, author, topic. These can be combined with each other. Examples
    • cat dog --matches anything with cat,dog or both
    • cat +dog --searches for cat +dog where dog is a mandatory term
    • cat -dog -- searches for cat excluding any result containing dog
    • [cats] —will restrict your search to results with topic named "cats"
    • [cats] [dogs] —will restrict your search to results with both topics, "cats", and "dogs"

FNames under the hood

I guess this is a question for someone-who-knows at Epic. But if you're already using FNames like this and it works please let me know!

If I declare FName variables in a project, and then load DataTables with fields which are FNames, into other classes, will the same FNames be given the same index etc? Can I still use comparators like == at FName speed? Presumably a conversion takes place from string to FName, when the excel spreadsheet is loaded into the project. Does that mean the engine will see two different FNames, even if they are the same string?

Thanks!!

Product Version: Not Selected
Tags:
more ▼

asked Sep 12 '14 at 09:04 AM in C++ Programming

avatar image

robbiecooper
766 79 61 235

(comments are locked)
10|2000 characters needed characters left
Viewable by all users

1 answer: sort voted first

Internally FName uses an index into a string table. Two FNames made with the same string (ignoring case-variations as FName is case-insensitive) will generate the same string table index, which is what's used by the FName == operator to compare them.

more ▼

answered Sep 12 '14 at 09:10 AM

avatar image

Jamie Dale STAFF
7.5k 177 67 305

avatar image gmpreussner STAFF Sep 12 '14 at 01:24 PM

Note that you should not store FNames on disk or serialize them over the network. They are guaranteed to be unique only within the local process (not even on the same machine). When persisting or serializing FName fields, convert them from and to FString instead.

avatar image Jamie Dale STAFF Sep 12 '14 at 01:33 PM

Some of our archivers have functions to automatically serialise/deserialise FNames in a persistent way (eg, ULinkerLoad, ULinkerSave, and UPackageMap) so if you're using a custom archiver, feel free to take a look at how those handle FNames.

avatar image NullBlack Oct 05 '16 at 02:48 PM

some clarification please: I've currently got save game data stored in maps keyed to FNames (mob stats keyed to the classes' FNames, NPC disposition keyed to NPCs' row names in data tables, chest contents keyed to level FName and chests' object FNames, etc). Will this work, or do I need to find something else to use as the keys?

avatar image alleysark Sep 06 '17 at 02:58 AM

It's bit an old question, but I am also confused to choose FName and FString. Is it OK to use FName for replication all the time?? Or should I replace all the FName variables in the unreal struct replicated on the network to FString?

avatar image ColdIronPoz Nov 21 '17 at 12:43 AM

FNames are replicated just fine over the network. If they aren't part of a special set of FNames hardcoded into the engine, they are automatically sent as FStrings. (You can find this logic in UPackageMap::SerializeName).

You don't want to save to disk or replicate the ComparisonIndex or DisplayIndex of an FName because they change depending what objects are loaded and what order they are loaded into the engine.

avatar image robbiecooper Sep 12 '14 at 01:43 PM

Awesome! Thanks for all the info and suggestions, its a big help.

(comments are locked)
10|2000 characters needed characters left
Viewable by all users
Your answer
toggle preview:

Up to 5 attachments (including images) can be used with a maximum of 5.2 MB each and 5.2 MB total.

Follow this question

Once you sign in you will be able to subscribe for any updates here

Answers to this question