Skip to content

Conversation

@DESTROYGIRL
Copy link
Contributor

@DESTROYGIRL DESTROYGIRL commented Jun 10, 2025

Description

Basic feature for specific things

neoAssets >>> NeotokyoRebuild/neoAssets#55

Toolchain

  • Windows MSVC VS2022

@DESTROYGIRL DESTROYGIRL added Enhancement New feature or request Changes in neoAssets This PR depends on changes in the neoAssets repository. The relevant PR should be in the description Mapping Entities, inputs and outputs. Things that are set up in the world editor labels Jun 10, 2025
@AdamTadeusz
Copy link
Contributor

image

@Rainyan
Copy link
Collaborator

Rainyan commented Jul 12, 2025

Basic feature for specific things

Could you describe the problem that this change addresses in a little more detail?

Also, do you have an example map where this new entity is used, for verifying this PR?

Looking at the change, it seems like you're implementing an explicit int/string/float type converter, I'm guessing to get around the failure case at:

if ( !Value.Convert( (fieldtype_t)dmap->dataDesc[i].fieldType ) )
{
// bad conversion
Warning( "!! ERROR: bad input/output link:\n!! %s(%s,%s) doesn't match type from %s(%s)\n",
STRING(m_iClassname), GetDebugName(), szInputName,
( pCaller != NULL ) ? STRING(pCaller->m_iClassname) : "<null>",
( pCaller != NULL ) ? STRING(pCaller->m_iName) : "<null>" );
return false;
}

But that failure check calls:

neo/src/game/server/cbase.cpp

Lines 1383 to 1390 in 23343df

//-----------------------------------------------------------------------------
// Purpose: Converts the variant to a new type. This function defines which I/O
// types can be automatically converted between. Connections that require
// an unsupported conversion will cause an error message at runtime.
// Input : newType - the type to convert to
// Output : Returns true on success, false if the conversion is not legal
//-----------------------------------------------------------------------------
bool variant_t::Convert( fieldtype_t newType )
which already handles conversions to boolean, float or integer for FIELD_INTEGER, FIELD_FLOAT, and FIELD_STRING.

Is there some specific case where this engine-native functionality is insufficient?

@Rainyan Rainyan self-requested a review July 12, 2025 10:14
@DESTROYGIRL
Copy link
Contributor Author

Could you describe the problem that this change addresses in a little more detail?

There are various entities that store numerical values as strings, or only accept strings when you would want to send an int/float value. The engine seems to convert between floats/ints fine from what I can tell (dont know if it gets rounded when dealing floats), but will always fail when trying to use a string output on a float input or vice versa.

There are a couple entities that have this problem but at the time of making this entity it was so I could display a variable number in point_worldtext. Rather than changing that entity specifically I thought it would be a better idea to make a unique entity that handles all cases where nessecary

I also considered adding functionality for vectors but wasn't really sure how to best implement it in a way that would be useful for the entities that support vector inputs/outputs

Rainyan and others added 2 commits July 13, 2025 21:50
@Rainyan Rainyan requested a review from a team July 14, 2025 16:43
@DESTROYGIRL DESTROYGIRL merged commit 65b7f3c into NeotokyoRebuild:master Jul 23, 2025
7 checks passed
@DESTROYGIRL DESTROYGIRL deleted the typeconverter branch July 23, 2025 14:02
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Changes in neoAssets This PR depends on changes in the neoAssets repository. The relevant PR should be in the description Enhancement New feature or request Mapping Entities, inputs and outputs. Things that are set up in the world editor

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants