View Issue Details

IDProjectCategoryView StatusLast Update
0000466Gameplay + OpenGL[All Projects] Featurepublic2017-03-29 13:30
ReporterNash 
Assigned To 
PrioritylowSeverityfeatureReproducibilityhave not tried
Status resolvedResolutionwon't fix 
Summary0000466: String argument for ConsoleProcess and SendNetworkEvent
DescriptionI'd like to be able to pass string parameters for ConsolePorcess and SendNetworkEvent.
TagsNo tags attached.

Relationships

Activities

Major Cooke

Major Cooke

2017-03-24 12:15

reporter   ~0001099

Last edited: 2017-03-24 12:17

View 3 revisions

You can work around this for the time being, with NetworkProcess.

In your event handler, add a boolean. Have it check for keywords, such as Enable/DisableReception, and allow it to accept what it sends along as strings for use. Then you send a keyword to disable it which takes priority over all other words it receives.

Here's an example.

 // deltas[num].receiving is my bool.
override void NetworkProcess(ConsoleEvent e)
{
    int num = e.Player;
    let plr = players[num].mo;
    
    if (plr)
    {
        if (e.Name == 'DisableReception')
        {
            deltas[num].receiving = false;
            Console.Printf("Disabled receiving.");
        }
        else if (deltas[num].receiving)
        {
            Console.Printf("%s, %d, %d", e.Name, e.Args[0], e.Args[1]);
            deltas[num].SetItem(e.Name, e.Args[0], e.Args[1]);
        }
        else if (e.Name == 'EnableReception')
        {
            deltas[num].receiving = true;
            Console.Printf("Enabled receiving.");
        }
        else if (e.Name == 'UpdateItems')
        {
            if (deltas[num].ItemName.Size() > 0)
            {
                for (int i = 0; i < deltas[num].ItemName.Size(); i++)
                {
                    Class<Inventory> item = deltas[num].ItemName[i];
                    if (item)
                    {
                        plr.A_SetInventory(item, deltas[num].Count[i]);
                    }
                }
            }
            deltas[num].ItemName.Clear();
            deltas[num].Count.Clear();			
        }
    }
}


Then whatever is doing the sending just does this:

D4DHandler.SendNetworkEvent("EnableReception",0,0,0);
    
for (int i = 0; i < m.ItemNames.Size(); i++)
{
    D4DHandler.SendNetworkEvent(m.ItemNames[i],m.Count[i],0,0);
}
D4DHandler.SendNetworkEvent("DisableReception",0,0,0);
D4DHandler.SendNetworkEvent("UpdateItems",0,0,0);


ZZYZX

ZZYZX

2017-03-25 10:15

reporter   ~0001106

Last edited: 2017-03-25 10:16

View 2 revisions

You can pass a string in the event name itself and then split it away using Mid.
e.g. event looks like this: "MyEventName:<data>"
You can receive <data> by doing this:
String eventF = "MyEventName:";
if (e.Name.Left(eventF.Len()) == eventF)
{
  String data = e.Name.Mid(eventF.Len());
}


Major Cooke

Major Cooke

2017-03-25 10:16

reporter   ~0001107

Last edited: 2017-03-25 10:16

View 2 revisions

Does mid go by n-1?

Nash

Nash

2017-03-25 12:45

reporter   ~0001109

Major Cooke: I need to pass unknown class names to my event, so I can't use your workaround.

ZZYZX: will try your solution and report back if it fits my needs, thanks.
Major Cooke

Major Cooke

2017-03-25 13:37

reporter   ~0001110

Last edited: 2017-03-25 13:37

View 2 revisions

That's what I did in mine.

Graf Zahl

Graf Zahl

2017-03-29 13:29

administrator   ~0001174

I think that sending the data encoded in the existing string is the best option here, the network protocol is really not the place to turn loose with parameters.

Issue History

Date Modified Username Field Change
2017-03-23 04:46 Nash New Issue
2017-03-24 12:15 Major Cooke Note Added: 0001099
2017-03-24 12:16 Major Cooke Note Edited: 0001099 View Revisions
2017-03-24 12:17 Major Cooke Note Edited: 0001099 View Revisions
2017-03-25 10:15 ZZYZX Note Added: 0001106
2017-03-25 10:16 Major Cooke Note Added: 0001107
2017-03-25 10:16 ZZYZX Note Edited: 0001106 View Revisions
2017-03-25 10:16 Major Cooke Note Edited: 0001107 View Revisions
2017-03-25 12:45 Nash Note Added: 0001109
2017-03-25 13:37 Major Cooke Note Added: 0001110
2017-03-25 13:37 Major Cooke Note Edited: 0001110 View Revisions
2017-03-29 13:29 Graf Zahl Note Added: 0001174
2017-03-29 13:30 Graf Zahl Status new => resolved
2017-03-29 13:30 Graf Zahl Resolution open => won't fix