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 8011307
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 4, 20262026-06-04T18:58:58+00:00 2026-06-04T18:58:58+00:00

I am currently implementing a game and want to add a Network feature. (i.e.

  • 0

I am currently implementing a game and want to add a Network feature. (i.e. I want to be able to join and host my application/game). This seems a lot tougher than I first imagined. The purpose of this question is asking if there is a good general datastructure choice for these kind of implementations.

My main problem is that I currently have a lot of functions in my Game class that look like this:

f() { if (host) doSomething() else doSomethingCompletelyDifferent() }

  • 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-06-04T18:58:59+00:00Added an answer on June 4, 2026 at 6:58 pm

    You could use OOP. Alas, you do not provide which programming language you use.

    For example, if you are programming in C, you could do

    struct thefunctions {
        void (*stuff1)(void);
        void (*stuff2)(int);
        int (*get)(int);
    };
    
    struct thefunctions network {
        .stuff1 = doSomething;
    }
    
    struct thefunctions standalone {
        .stuff1 = doSomethingCompletelyDifferent;
    }
    
    struct thefunctions * funcs;
    
    [...]
    
    if (host) {
        funcs = &network;
    } else {
        funcs = &standalone;
    }
    
    // now the structs are initialized. We can now use funcs->.
    
    [...]
    
    // If I am sure that stuff1 has been initialited properly, I can do
    funcs->stuff1();
    
    // If not, I should check first
    if (funcs->stuff1) funcs->stuff1();
    
    // or
    assert(funcs->stuff1);
    funcs->stuff1();
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I am currently in the middle of implementing the network layer of my game,
i am implementing one game application in this application i am using shared preferences
Im currently implementing an update feature into an app that I'm building. It uses
I'm currently implementing a custom MultiPageEditorPart where I want to have multiple pages when
I'm currently implementing Highcharts to create graphs in my RAILS application. I'm using the
I'm currently implementing functionality in Tridion 2009 SP1 where the user is able to
I'm currently implementing a feature to micropost posting where a user can link to
** I am currently implementing fancy URLs to see if these 'solves' this. eg
I want to create screen-in-screen functionality in my HTML5 game, and to do this
I'm currently implementing a radix tree/patricia trie (whatever you want to call it). I

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.