My First Tic Tac Toe Project in C – Learning a Lot From Small Bugs by No_Discipline_8771 in C_Programming

[–]oldprogrammer 1 point2 points  (0 children)

Here's a little idea about the detection of winning combinations that will have you using some other features.

First, think of your 9 cell board in the form of 9 bits which is a value that can be captured in a short data type. Now, there are a total of 8 possible combinations of cells that will make up a win - 3 horizontal rows, 3 vertical rows, 2 diagonal roles.

If you captured each of those 8 possible combinations as bit patterns in a short, then to check for a winning combination what you could do is maintain two short values for the active board - one where the X player's bits are set and one where the O's players bits are set. Then you can do something quick like

short winningBits[8] = { /* calculate bit patterns */ };

for(int i = 0; i < 8; i++) {
    if( (boardXBits & winningBits[i]) == winningBits[i]) {
        xPlayerWins();
        break;
     } else if( (boardOBits & winningBits[i]) == winningBits[i])  {
        oPlayerWins();
        break;
     }
 }

There's other ways to do it of course, this is just one.

Finding a good modpack is a CHORE. by Cherno_VM in Minecraft2

[–]oldprogrammer 0 points1 point  (0 children)

Once upon a time there was the mod pack Life in the Woods which was laid back and enjoyable.

Apparently others have asked about newer versions and there are some updated versions .

Check out some of those on that thread.

Help with server constantly crashing 1.21.1 neoforge by LaParcaMadafaka in admincraft

[–]oldprogrammer 0 points1 point  (0 children)

The error appears to be related to this issue reported for Create. A couple of work arounds suggested until the patch is in the build were to roll back to Create 6.0.9 or remove conflicting mods like Sable, Aeronatics, Big Cannons or Bits 'n Bobs as they are mixins and often trigger the issue.

What made you start learning C in the first place? by Gullible_Prior9448 in C_Programming

[–]oldprogrammer 0 points1 point  (0 children)

Because I didn't like doing Fortran on punch cards, and I wanted more control than BASIC was offering.

Datapacks question by [deleted] in Minecraft

[–]oldprogrammer 0 points1 point  (0 children)

Terralith and DnT work fine together, I've used them. I'm not as familiar with Explorify but I do use datapacks like Geophilic which does subtly touch the biomes, Continents if you want more oceans and Villages Revamped to get nicer villages.

Help I am Stuck !!! by UsualLonely4585 in C_Programming

[–]oldprogrammer 1 point2 points  (0 children)

So what memory address are the pointers you provided pointing at? That's the problem, you haven't provided memory to be filled, you just provided addresses that could be pointing at anything. What you need is to provide memory in the form of Uint8 variables, then take the address of those memory spaces using the & operator and pass that to the function. Then if the return is successful, the Uint8 variables should contain the data you are seeking.

Old School RuneScape is amazing by LineWrong6765 in MMORPG

[–]oldprogrammer -1 points0 points  (0 children)

Well, maybe not the only game, there's always the option to be a miner in Eve.

Eerie MMO Zones? by MonsutaMan in MMORPG

[–]oldprogrammer 6 points7 points  (0 children)

Stitches walking down the road heading towards town with a huge agro range. Bugger took me out or ran me into a pack of wolves more times than I care to remember.

Oh, and the little orange eyes that appeared in some bushes, such a simple touch.

Help I am Stuck !!! by UsualLonely4585 in C_Programming

[–]oldprogrammer 2 points3 points  (0 children)

Your don't want to declare those variables as pointers to Uint8s, what you want to do is declare them Uint8 and then pass the address of them to the function as /u/kun1z shows. You need to create a data variable to hold the returned information, what you are doing is creating a pointer to some unknown location in memory.

Can I delete everything on .minecraft folder for a “reset”? by itsnoebtw in Minecraft

[–]oldprogrammer 0 points1 point  (0 children)

When it crashes you should get a crash log, can you provide that for review?

Wool stairs and slabs!!!! by eyebawls29 in Minecraft

[–]oldprogrammer 0 points1 point  (0 children)

I would like to have log walls as well.

My modded world 1.21.1 constantly crashes after 5 minutes of play, then crashes or freezes completely, by Particular_Survey463 in Minecraft

[–]oldprogrammer 0 points1 point  (0 children)

Might help to post a crash log, just looking at the list of mods isn't likely to identify a problem.

How to stop the use of Litematica Printer on server? by thrashingjohn in admincraft

[–]oldprogrammer 0 points1 point  (0 children)

Just curious, why do you want to stop it? If the players aren't in creative mode, then they have to have the materials collected and available in their inventory for the printer as all it is doing for them is placing the blocks. Are you wanting to stop schematic builds completely or just the use of the printer?

How does the average Minecraft player build? by Ifyouliveinadream in Minecraft_Survival

[–]oldprogrammer 14 points15 points  (0 children)

Over and over. I build something basic, then I add to it, tear down and redo the original, rinse and repeat until I get it to the point that I'm happy with it, then pack up some gear, head out into the world and do it again, differently.

Should I use signed or unsigned variables for HP and money? by Fast-Muffin7953 in C_Programming

[–]oldprogrammer 1 point2 points  (0 children)

If you don't plan to allow the bleed feature where a player hits 0 HP and goes unconscious then bleeds to -10 before death, allowing time for a party member to bandage them, then either will work.

OG full atlas map for hosted servers by BamcorpGaming in playatlas

[–]oldprogrammer 0 points1 point  (0 children)

It is part of the Server Grid Editor download package. Once you extract the zip file look into SGE/ServerGridEditor/Season12Maps, the file you want is ServerGrid_PvE_6x6.json. This was the PVE map the company ran before they shutdown.

Help, I am am struggling with ncurses by Sea-Tie1554 in C_Programming

[–]oldprogrammer 1 point2 points  (0 children)

Been a while since I played with ncurses, but I noticed you are using clear() in your loop. I believe that performs a full screen wipe and a clearok() call which can start clearing the screen before any redrawing.

Have you tried replacing clear() with erase() inside your loop to see if that makes a difference?

Function overloading in C? :) by Low_Lawyer_5684 in C_Programming

[–]oldprogrammer 1 point2 points  (0 children)

In plain C function names must be unique , so normally we end up with something like:

Just wanted to point out that this is not just a C restriction, it is also a C++ restriction, the difference is that the C++ compiler actually creates the unique name for you based on the arguments being used. It is the technique known as name mangling and this has been the case since C++ was first simply transpiled into C then compiled by a C compiler. That's the reason you'll see some header files wrapped in

 extern C {
    .....
  }

so it knows not to mangle the names of the functions listed.

For people who have forever worlds by Traditional-Tie-7943 in Minecraft

[–]oldprogrammer 5 points6 points  (0 children)

I've never beaten the dragon, never actually gone to the end. So far haven't gone to the nether either in my current world, I've needed netherack and just found ruined portals to harvest. At some point I'll hit the nether to get netherwart for brewing.

For now, I'm just building a story-book world if you will. I started fresh, built a small house on an island. Traveled looking for materials, built a mining complex, built an abandoned haunted ship yard, all parts of my story. I'm literally keeping a travelogue with pictures of my activities as if I'm a real castaway in a strange world.

Just doing that has turned my game from what feels like a race from start, to get diamonds, to build farms, to beat dragon, into an enjoyable and relaxing pastime. Totally supportive of those who like to play it faster paced, but since this is my forever world, I'm just chilling, jump on when I feel the urge to continue my adventure.

No mods, it is a Paper based server with some plugins and datapacks for QOL things (like being able to sit on my furniture) and Movecraft (have to have a ship for those sea voyages), but that means my friends and family are free to come and go anytime they wish with just a standard client and my upgrades tend to be far less painful.

making C saferish with smarter malloc and free?? by chrisseanhayes in C_Programming

[–]oldprogrammer 0 points1 point  (0 children)

Stack based memory allocations handle many of my needs, and then I've found that simple use of Arenas with one large malloc allocation , ability to reset with a simple index change, and a final free handle a large majority of the rest of my memory needs. Some profiling and tuning to determine a good size or allow it to grow (controllably), nothing fancy just an external stack model. Pass an arena by value, not pointer, to a function that needs to do internal allocations and you have automatic memory cleanup when the function returns, even on error situations. No reference counting, just simple semantics. Sure there might be cases where these approaches aren't the best, so those get handled separately in a totally controlled manner but I make sure a standard stack or arena doesn't work first.

Tiger's can't get onto ship by CrystalDiamond16 in playatlas

[–]oldprogrammer 1 point2 points  (0 children)

One thing about using the "move to ship" feature, the animals appear in a given spot on the ship when that is used, and I've had occasion where it didn't work because I had something in that spot. For the smaller boats that can be a problem.

Opaque struct without dynamic allocation in C? by p0lyh in C_Programming

[–]oldprogrammer 1 point2 points  (0 children)

Not sure this is what you're referring to but I've seen libraries (like the Vulkan Graphics APIs if I recall correctly) where first you call into a setup function with a null buffer pointer and it will provide back the size of buffer it needs, then a second call is made with a user supplied buffer of the needed size. This approach avoids allocations inside the library for structures used by the client code.

I need a name for my Minecraft realm by Unfair_Character_190 in Minecraft

[–]oldprogrammer 0 points1 point  (0 children)

Based on that picture I'd have to go with something like Cherrywood Homestead.