10/2/2016 · Forex Girl Vroulike / Vrou / Girl Handelaars hier. Dit is normaal wanneer 'n paar vroue in te samel in 'n plek of forum om oor te bespreek 'n paar dinge wat oninteressant of vervelig om mans.
What is Your Motivation to Be a Forex Trader? Partner Center Find a Broker. Why do you want to become a forex trader? Is it because the girl you like trades currencies and you want to impress her? It is important to know what your true motivation is, or whether you should even be trading at all.
In a forex trade, you buy one currency while simultaneously selling another - that is, you're exchanging the sold currency for the one you're buying. The foreign exchange market is an over-the-counter market.
Currently in market daniel wilczek forex the bestselling black head nose is the YC Black head charcoal nose mask. The window, which offers investors the opportunity to sell dollars at rates of their choice, provided they find willing buyers, has restored confidence to the forex market and boosted the foreign exchange reserves.
Girls Gone Forex was born out of the desire to empower women to be great in everything that we do. Women are grossly underrepresented in the Forex industry and financial markets in general. However it has been proven that women tend to trade better than men.
. 20 likes. Community. Jump to. Sections of this page. Accessibility Help. Press alt + / to open this menu. Facebook. Email or Phone: Password: Forgot account? Home. Reviews. About. Photos. Posts. Community. Info and Ads. See more of on Facebook. Log In. or. Create New Account. See more of on Facebook.
6/4/2013 · The sarah from jordan: my acquaintance with the Forex market has started accidently - in July 2011 I started reading the book "To play at the exchange market is easy". Starting reading second chapter I have opened a demo account, and made a decision to find out how it works.
As a Financial Coach, Master Forex Trainer and former Money Manager, Linda brings a wealth of knowledge and experience to Girls Gone Forex which is evident in the Trade Like A Girl Academy curriculum and the 20/20 Trading System.
girl_forex commented on a post in r/todayilearned 35.1k TIL of Khassan Baiev who was the single surgeon for over 80.000 during the Chechen wars and at one point during the conflict he performed 67 amputations and eight brain operations in a 48-hour period.
Bunny Girl System is an Forex Trading system with WMA and RSI. Bunny Girl System is an Forex Trading system with WMA and RSI. Free Forex Strategies, Forex indicators, forex resources and free forex forecast. Forex Strategies Resources. Home Page 38# Bunny Girl Trading System.
Trade Like A Girl Academy offers a proprietary curriculum and Forex training program designed to turn a student with zero knowledge of the Forex markets into a disciplined Forex trader, a savvy Forex investor and/or an innovative Forex trading programmer.
5/26/2008 · Wizetrade: Lindsay Hall Bio. FOREX market. Lindsay has taught thousands of clients at 2-Day Hands-On Training classes and via her launch of the 6:00 a.m. (ET) 4XTalk™ Live online broadcast, which set records for numbers of listeners. Lindsay is the on-air expert appearing on The Morning Edge, On the Spot and Future Focus.


Our school day is well balanced between classroom instruction, outdoor play and physical education, music and more. We offer a full-day kindergarten program, which allows students time for quality instruction as well as age-appropriate play, rest, and social interaction. A typical K-5 School Day begins at 8:25 AM and ends at 2:55 PM.


A delicate blend of New Zealand's finest ovine placental protein, vitamin E and lanolin. This product helps to combat wrinkles and rejuvenate skin cells.
Placental protein is a rich source of bioactive nutrients providing intense hydration, firming of the skin and helps reduce the impact of the aging process on your skin.
This product has enhanced moisturising qualities with the addition of vitamin E. Vitamin E is easily absorbed and promotes blood circulation in the skin. Vitamin E, an antioxidant, also helps to prevent keratinisation, keeping the skin moist and inhibiting melanin deposits.


text:
DeadReckoning or Other?
Technical Programming
system April 16, 2003, 9:41pm #1
I was just wondering how many of the teams out there used Dead Reckoning for their autonomous program and how many teams used some other sort of autonomous…
Cipher X
i think that dead reckoning was the easiest. but 1 team i saw had like 10 sensors in the from im guessing line tracking but it was insane.
Telly April 16, 2003, 9:53pm #3
Our team had a set radius which was made by have the outside wheel spin faster and used a gyro to know when it turn 180 degrees at which point it continued up the ramp.
system April 16, 2003, 10:09pm #4
Well, We originally had our robot set to with a line tracker that used 6 sensors to follow the line to the ramp. It worked but after we used it in competition we realized that it was way to slow. We then wrote a dead reckoning program to bring it up the ramp in the same format as the line tracker but without sensing the line. At Nat's we decided to modify the dead reckoning. We angled the robot so it would drive strait out until it was about even with the side of the ramp. Then turned it about 45 degrees and sent it up the ramp. It worked quite well for a while until some mechanical difficulties slowed our robot down. We then decided to make a program that brought our robot back under the bar in autonomous so that we could defend the stack. By the end of Nats we had about 5 or 6 different auto modes.
Gabriel April 27, 2003, 12:12pm #5
We used rotation counters on the wheels (a magnetic read switch and four magnets) and it worked perfectly at UTC and on Friday at Nationals. By the end of friday and saturday we were veering off course. Perhaps using an optical sensor to count rotations would have been more accurate.
ZACH_P April 27, 2003, 12:35pm #6
My team had 8 autonomy modes, plus their inverses for use on the other side of the ramp, for a grand total of 16 autonomous modes. The method we used was that our programmer wrote a program to record the signals sent from the joysticks and then save them to play them back at a l ater time. this worked beautifully, and I am still amazed at the skill of our programmer.
Jessica_166 April 27, 2003, 2:45pm #7
While our team did have a line tracking program, we chose to use dead reckoning. We had about three different dead reckoning programs, but we only ever used the one that went up the ramp. We also had our robot start at and angle and drive straight until it was in center with the ramp and then it turned a small degree and went up the ramp. It worked quite well when it was perfected. In one match, to our whole team's amazement we watched our robot push another robot over the ramp during autonomy. That was pretty cool!
Some of the other programs we had but never chose to use were:
a program to sweep the field to clear out stacks and
a program that drove backwards to knock the robot behind us off course.
Kevin_A April 27, 2003, 2:52pm #8
We were supposed to be line following, but gave up, and went autonomous. We had one that went up the middle of the ramp, one that went up the inside edge of the ramp and one that went under the bar and messed up our oppenents robot. The latter was my fav!
Daniel_Brim April 27, 2003, 4:39pm #9
Team 294 had a line tracking program. It worked, but it would take more than 15 seconds to get up top so we used Dead Reckoning

redpajama_set_name: RedPajamaCommonCrawl


text:
Q: Linux - How to list all device nodes using a specific device driver I know I can see what driver is being used for a device node if I know the major and minor number of the device(see this link).
But I want to know if there's a way to list all device nodes that are using a particular driver by just giving the driver name.
Say the name of the device driver is 'vpfe-capture', then I'd want to know all device nodes using 'vpfe-capture'.
This would save the time of manually searching through each device node in /sys/dev/ just to see which nodes use a particular driver.

redpajama_set_name: RedPajamaStackExchange


text:
10.24.16 October 24, 2016
One Doom fan, 300 hours, and one gargantuan level
by Zack Zweizen
@zwiezenz
The first time I ever made a Doom map I simply created a few rooms and hallways, then added a couple of enemies and some ammo. But Ben Mansell created something a little more complex with his first Doom map. After 300 hours and over a year spent on it, Mansell is ready to unleash Four Site into the world. A map so large it will take most players two to three hours to complete.
Four Site is massive—essentially four decent-sized Doom maps put together. Each section has its own look and feel, and the pacing is unlike many modern Doom maps I've played. Modern Doom maps seem to focus on using more powerful hardware to throw bigger waves of enemies at the player. With Four Site, Mansell wanted to create a map that hearkened back to the older maps found in the original Doom (1993) and Doom II (1994).
But he was also inspired by another series of games: "If there was one big influence, it wasn't Doom at all, but the Dark Souls series," said Mansell. "Some of Miyazaki's levels in the series are masterclasses in progression, non-linearity, and environmental storytelling." He specified that a level like Tower of Latria from Demon's Souls (2009) was perfect example of how to "unfold a level to a player." Tower of Latria left an impact on Mansell, as he explained: "There's a prison section later on in my map that in hindsight is pretty much a direct tribute to [Latria]."
The idea for the map has been in Mansell's brain since 2003—it was then that Mansell, while in a college lecture, started doodling the idea for a Doom map. "Somewhere in my old lecture notes there's probably a roughly drawn outline of the map!" said Mansell. But he never did anything with the idea until last year. He had no idea if he would even be able to make Four Site. He described the process as a "trial by fire."
"That room alone probably took 30 hours or more to get right"
As said, it took him over 300 hours to put Four Site together, not to mention months and months of planning on paper. Some sections of the map came together relatively quickly, other sections, however, took considerably longer. One such section was an ascending tower found in the last part of the second section.
"Working out how to get the Lost Souls to teleport in at the right time at the right height (given Doom handles height in a rather limited way) took a lot of head-scratching," Mansell said. "I ended up with a spreadsheet of different heights and formulas to work out where to position the Lost Soul spawn-points. That room alone probably took 30 hours or more to get right."
-Ben Mansell's 1 hour playthrough of his massive Doom level, Four Site
With Four Site finished, Mansell has made the map available to anyone who has a copy of Doom II. He was surprised by the reaction the map got after posting it on Reddit. Within days it was being covered by numerous sites and being shared across Twitter and forums. As to why the map has become so popular, Mansell believe it's partially due to nostalgia: "My map perhaps struck a chord by being so resolutely old-school yet still unusually large. It's quite a traditional Doom map in some senses, following the kind of nonlinear, sprawling design principals many modern FPSs shy away from."
Mansell wants to make another Doom map, but he's going to take a break first. Instead, he is going to play maps made by other creators. "I've about six years of Doomworld.com Cacoward winners to catch up on, so I don't think I'll be short of amazing Doom maps to play any time soon!"
You can download the Four Site .wad here and use GZdoom, a modern sourceport, to play it.
Zack Zweizen
Zack Zwiezen can usually be found wandering the streets of Kansas City trying to explain to people why Jurassic Park Operation Genesis is a great game.
Ben MansellCustom WaddoomDOOM IIDoombuilderFour Site
← The Curious Expedition is a disturbing portrait of the colonial mind
Jason Rohrer's next game is a twisted take on child rearing →


LEHIGH VALLEY, Pa., June 20, 2018 /PRNewswire/ -- Air Products (NYSE: APD), the leading global hydrogen provider, today held a ribbon-cutting event at the Covestro LLC Baytown, Texas, industrial park, where Air Products has invested over $350 million to build, own and operate a world-scale steam methane reformer (SMR). The SMR is producing hydrogen and carbon monoxide (CO) to be supplied at Baytown to Covestro and to other customers linked to Air Products' Gulf Coast Hydrogen and CO Pipeline Networks.
"Our decades-long relationship with Covestro and its predecessor companies continues to grow with this new facility in Baytown. Our new plant is important to our host site customer Covestro for the carbon monoxide produced, but the facility also offers other benefits to Air Products, other customers, and even the general public. The new SMR strengthens Air Products' position in the Texas CO market, and it increases the product capacity of our well-established hydrogen pipeline supply network while creating a product necessary to making cleaner burning transportation fuels, which helps to keep the air we breathe cleaner," said Marie Ffolkes, president‒Industrial Gases Americas at Air Products.
The SMR and cold box are both located on land leased from Covestro, a world-leading manufacturer of high-tech polymer materials for diverse industries, such as automotive, construction and furniture. The SMR produces approximately 125 million standard cubic feet per day (mmscfd) of hydrogen and a world-scale supply of carbon monoxide, a critical raw material for Covestro's chemical production in Baytown.
"We're proud to host Air Products and its world-class SMR facility at our Baytown Industrial Park," said Rod Herrick, vice president, Covestro Baytown Industrial Park. "We're always exploring new opportunities to increase the reliability and efficiency of our Baytown operations, and today marks an important milestone on that journey. The new SMR facility will strengthen our regional supply network, which in turn allows us to better serve our customers."
Air Products' new SMR was built through the global hydrogen alliance between Air Products and TechnipFMC, a global leader in subsea onshore/offshore, and surface projects for the energy industry. The plant features the latest technology to maximize energy efficiency and reduce emissions, and includes optimal heat integration, which in turn lowers feedstock consumption. The plant configuration and deployed technologies support Air Products' overall sustainability goals of reducing energy consumption and emissions.
Ffolkes added that Air Products' ability for the new plant to connect to its existing Gulf Coast Pipeline (GCP), the world's largest hydrogen plant and pipeline network system, remains a value-added plus for hydrogen customers in terms of ensuring product reliability. In April 2018, Air Products announced another increase to the supply capacity of its GCP supply network by approximately 40 mmscfd from processing hydrogen-rich off-gas from a propane dehydrogenation plant in Mont Belvieu, Texas. Air Products officially innaugurated its GCP in 2012. The 600-mile pipeline span stretches from the Houston Ship Channel in Texas to New Orleans, Louisiana, and supplies customers with over 1.4 billion feet of hydrogen per day from 23 hydrogen production facilities.
Pipelines offer a safe, robust and reliable supply of hydrogen to the refinery and petrochemical industries around the world. Globally, Air Products' pipeline operational expertise is evidenced by its network of systems. Besides the GCP, Air Products also has a hydrogen pipeline in California in the U.S., in Sarnia, Ontario, Canada, and in Rotterdam, the Netherlands.
Covestro's Baytown facility, its largest plant in North and Central America, was established in 1971 and hosts approximately 2,000 workers onsite. Covestro's primary products at its Baytown site include toluene diisocyanate (TDI) and methylene diphenylene isocyanates (MDI), in addition to coatings and adhesives, inorganic basic chemicals, polycarbonates, and polyurethanes. It is a leading supplier of high-value polymers and innovative solutions for key sectors such as transportation, construction, electronics, furniture, sports equipment and textiles.
TechnipFMC plc is a global leader in subsea, onshore/offshore, and surface projects. With our proprietary technologies and production systems, integrated expertise, and comprehensive solutions, we are transforming our clients' project economics.
To learn more about us and how we are enhancing the performance of the world's energy industry, go to TechnipFMC.com and follow us on [email protected].
For more than 25 years, the Air Products and Technip global alliance has provided the worldwide refining industry with competitive technology and world-class safety. The alliance is responsible for over 35 hydrogen production plants located in 11 countries around the world and produces well over two billion standard cubic feet of hydrogen per day for clean fuels production. TechnipFMC provides the design and construction expertise for steam reformers, while Air Products provides the gas separation technology. Air Products, through its extensive operating network, and Technip, from its large reference base, also bring effective operational and engineering knowledge to "design-in" high reliability and efficiency. The plants are operated and maintained by Air Products under long-term agreements with customers.
NOTE: This release may contain forward-looking statements within the safe harbor provisions of the Private Securities Litigation Reform Act of 1995. These forward-looking statements are based on management's reasonable expectations and assumptions as of the date of this release regarding important risk factors. Actual performance and financial results may differ materially from projections and estimates expressed in the forward-looking statements because of many factors not anticipated by management, including risk factors described in the company's Form 10K for its fiscal year ended September 30, 2017.
EDITOR'S NOTE : Downloadable photos of the Baytown facility and ribbon-cutting event are available in Air Products' online News Center.


text:
New Trailer and 3 New Character Posters for "The Kitchen"
Home » Comics » NYCC: How To Survive In A Dystopian World
NYCC: How To Survive In A Dystopian World
Posted by Dan Wickline October 9, 2014 Comment
Christine Marie Vinciquarra writes for Bleeding Cool:
The How to Survive in a Dystopian World panel started with a ton of laughter as moderator Scott Westerfield started off by saying "so many dystopias, so little time." Isn't that the truth! The panel of seven authors consiting of James Dashner, Margaret Stohl, Pierce Brown, Rachel Cohn, Alex London, Maya Rock, and Joshua David Bellin, quickly chimed in with tid bits about their own books. The conversation began to lean towards, whether or not the age of dystopian fiction is coming to a close. The consensus was people aren't tired of dystopia, they're tired of bad dystopia. Westerfield argued that he had just been on a book tour and met tons of YA readers that didn't voice any hatred towards the genre continuing. He then joked, "we are just going to read books about cancer from now on." (A friendly nod to John Green.)
As the panel continued Margaret Stohl proved to be the most energetic out of the seven authors, and egged the crowd on to cheer as loud as we could keeping the energy in the room high. Westerfield continued with a discussion about control in the dystopian societies. They usually fall into two categories, some with too much control, and some with too little control. Going down the panel, the balance was pretty even. About half claimed that their societies had too much control, and the other half stated the opposite.
One of the highlights for this panel for me was the discussion about why kids love dystopian books so much. Alex London talked about how being a teenager is a lot like being in a dystopia. You struggle with power, and you learn how to exercise it, and of course you make some mistakes. Stohl continued that teenagers are hyper aware of the marketplace, and they are empowered to make decisions about what's a trend and what's not. Dashner chimed in about how trends have changed over the years. After Harry Potter took over the world, vampires came, then dystopian came. Dystopian has an added layer of fascination because these things could happen. "What if this really did happen to us?"
Dashner's point led into discussion about the real world, and how it is very possible that we will face things that these characters are facing in the future. He spoke about his own predictions by saying, "Viruses terrify me. There is no doubt in my mind that when the world starts to crumble it will be because of a virus." I have to agree with him on that one.
Overall, the panel was a lively memorable discussion. One final note that I want to mention is, when the panel was asked what they would miss if they lived in a Dystopian world most said toilet paper, and others joked Netflix and Hulu Plus.
Christine Marie Vinciquarra is a writer and bibliomaniac with a love for all things creative. Some of her favorite things include: Batgirl, Star Wars, Harry Potter, Saga, Game of Thrones (the books and the show), Johnny Depp, and all things Disney. She spends her weekends feeding her competitive side while she plays tabletop and/or video games with her husband and friends. She is currently working on a series of young adult fantasy novels. You can find her on Twitter and Instagram @AWritersWay or on her blog writerchristinemarie.wordpress.com.
About Dan Wickline
Has quietly been working at Bleeding Cool for over three years. He has written comics for Image, Top Cow, Shadowline, Avatar, IDW, Dynamite, Moonstone, Humanoids and Zenescope. He is the author of the Lucius Fogg series of novels and a published photographer.
(Last Updated October 9, 2014 9:25 pm )
Dynamite To Publish Over-Sized Vampirella #100
And Finally… The Fear Of A Horse Running Amok On The Streets Of New York City


While quick to express solidarity with the victims of Sunday's terror attack, the Council on American-Islamic Relations has long ignored Muslim American LGBT activists.
The Council on American-Islamic Relations (CAIR) has touched the hearts of many journalists since an ISIS-inspired terror attack left 49 dead at a gay nightclub in Orlando early Sunday morning. CAIR Executive Director Nihad Awad called for solidarity with "all communities who are the victims of violence and persecution in our country." CAIR-San Francisco Director Zahra Billoo vowed to "stand with the LGBT community against homophobic violence." The head of the organization's Florida chapter, Hassan Shibly, declared his "overwhelming love and support and unity" for the LGBT community.
In light of Islam's well-known prohibitions against homosexuality, it's great to hear such words in any context.
But let's not kid ourselves. CAIR was founded by members of the Sunni Islamist Muslim Brotherhood, whose hatred of homosexuals is quite explicit. Shibly himself decried homosexuality as "evil" and a "quick way to earn God's wrath" in a 2009 Facebook essay on gay marriage.
Most CAIR officials have avoided expressing anti-LGBT opinions publicly.
In order not to jeopardize their pursuit of U.S. governmental access and partnerships with left wing anti-Israel activists, most CAIR officials have avoided expressing such opinions publicly. More often they have ignored the issue of homosexuality or denied that it is prevalent in the Muslim community. Echoing the laughable claims of former Iranian president Mahmoud Ahmadinejad that his country has no homosexuals, CAIR-Chicago director Ahmed Rehab once objected to the presence of a gay Muslim American character in a local theater production, saying that homosexuality is an issue "not...very prevalent in the Muslim community" that was "imposed upon it by the play makers."
Moreover, CAIR coordinates very closely with other Islamist organizations that have not felt the need to bite their tongues when talking about homosexuality. Tahirah Amatul Wadud, a member of the CAIR-Massachusetts Executive Board of Directors, also happens to be general counsel for the notoriously anti-gay organization The Muslims of America Inc. (TMOA), led by Mubarak Ali Gilani (for high-profile cases handled at TMOA by Wadud, see here and here). Gilani called the U.S. Supreme Court's legalization of gay marriage on June 26, 2015 "a black day in the history of mankind."
CAIR frequently hosts Muslim preachers known for virulent anti-gay rhetoric.
CAIR frequently hosts events featuring Muslim preachers known for virulent anti-gay rhetoric. A frequent speaker at CAIR fundraisers, Siraj Wahhaj, famously threatened to burn down a proposed LGBT-friendly mosque in Toronto in 1992. Suhaib Webb, another favorite of CAIR events, called homosexuality an "evil inclination" in 2007. Omar Suleiman, who has recorded numerous promotional videos for CAIR, has called homosexuality a "disease" and a "repugnant, shameless sin." Islamic Shura Council of Southern California leader Muzammil Siddiqi, with whom CAIR held a joint press conference following the December 2015 San Bernardino terror attack, has advocated the death penalty for homosexuals in Muslim countries.
In short, CAIR has done nothing to stand up for the rights of LGBT Americans or promote more tolerant Muslim-American attitudes toward sexual orientation, while giving radical Islamist preachers on whom it depends for support a platform for anti-gay incitement.
CAIR's sudden expressions of affinity for the LGBT community are nothing more than damage control, designed to obscure its role in propagating the murderous ideology that led Orlando shooter Omar Mateen on his rampage. Fancy PR footwork aside, CAIR is part of the problem, not part of the solution.


text:
#pragma optimize( "", off ) // JB 010718

#include <objbase.h>
#include <cguid.h>
#include <dplay8.h>
#include <initguid.h>

#include "F4Comms.h"
#include "falclib.h"
#include "capiopt.h"
#include "Comms/udp.h"
#include "Comms/rudp.h"
#include "router.h" //KCK This needs to go away
#include "UI/INCLUDE/uicomms.h" // UI comms manager
#include "falclib/include/msginc/sendchatmessage.h"
#include "FALCLIB/INCLUDE/f4find.h"
#include "FalcMesg.h"
#include "MsgInc/TimingMsg.h"
#include "Falcmesg.h"
#include "DispCfg.h"
#include "CmpClass.h"
#include "ComData.h"
#include "UI/INCLUDE/queue.h"
#include "UI/INCLUDE/falcuser.h"
#include "TimerThread.h"
#include "acselect.h"
#include "pilot.h"
#include "flight.h"
#include "voicecomunication/voicecom.h"
#include "FALCLIB/INCLUDE/MsgInc/PlayerStatusMsg.h"
#include "FALCLIB/INCLUDE/MsgInc/SimCampMsg.h"
#include "aircrft.h"
#include "SimBase.h"

// ==============================================
// Insert DPLAY crap here
// ==============================================

DEFINE_GUID (OVERRIDE_GUID, 0x126e6180, 0xd307, 0x11d0, 0x9c, 0x4f, 0x0, 0xa0, 0xc9, 0x5, 0x42, 0x5e);
GUID	gOurGUID = OVERRIDE_GUID;

// ========================================================================
// Some defines
// ========================================================================

#define F4COMMS_CONNECTION_TIMEOUT_SECS 8

#define F4COMMS_CONNECTED_TO_NO_ONE		0
#define F4COMMS_PARTIALLY_CONNECTED		1
#define F4COMMS_FULLY_CONNECTED			2

// KCK: These really need to come from comms itself!!
#define COMMS_TCP_OVERHEAD				40
#define COMMS_UDP_OVERHEAD				12

#define F4COMMS_MAX_PACKETS				32

// ====================================
// Globals
// ====================================

ComAPIHandle FalconTCPListenHandle = NULL;
ComAPIHandle FalconGlobalUDPHandle = NULL;
ComAPIHandle FalconGlobalTCPHandle = NULL;
//ComAPIHandle FalconInitialUDPHandle = NULL;
int FalconServerTCPStatus = VU_CONN_INACTIVE;
int FalconConnectionProtocol = 0;
int FalconConnectionType = 0;
int FalconConnectionDescription = 0;
int gConnectionStatus = 0;
int gTimeModeServer = 0;
int g_b_forcebandwidth = 0;
extern bool g_bServer;

//DCNode *DanglingConnections = NULL;
FalconPrivateList *DanglingSessionsList = NULL;

// debug bandwidth limiters
int F4CommsBandwidth = 0;
int F4CommsLatency = 100;
int F4CommsDropInterval = 0;
int F4CommsSwapInterval = 0;
int F4SessionUpdateTime = 0;
int F4SessionAliveTimeout = 0;
int F4CommsMTU = 0; // MTU variable declared Unz
extern bool g_bF4CommsMTU; // Unz switch for MTU
// ========================================================================
// Message sizing variables
// ========================================================================

// Ideal packet size we'll send over the wire;
int	F4CommsIdealPacketSize;
// Corrisponding content sizes
int F4CommsIdealTCPPacketSize;
int F4CommsIdealUDPPacketSize;
// Corrisponding messages sizes
int F4CommsMaxTCPMessageSize;
int F4CommsMaxUDPMessageSize;
// Maximum sized message vu can accept
int F4VuMaxTCPMessageSize;
int F4VuMaxUDPMessageSize;
// Maximum sized packet vu with pack messages into
int F4VuMaxTCPPackSize;
int F4VuMaxUDPPackSize;

// ====================================
// Prototypes: sfr: moved to header file
// ====================================

//void SendConnectionList (FalconSessionEntity *session);

// ====================================
// COMMS startup and shutdown stuff
// ====================================

// This sets up a comms session (both udp and tcp handles) using the current protocol.
// FalconGlobalHandles are handles to the whole world (ie: broadcast on a LAN, or a server address,
// or NULL if not available)
// tcpListenHandle is a listen handle where we can recieve tcp connection requests.
//
// InitCommsStuff takes the following parameters:
// int GameType:				Nonzero if a game is currently running and needs to
//								Attach to a group immediately.
// FalconConnectionType fct:	FalconConnectionType enumerated type
// ulong IPAddress:				IPAddress of server or other machine, if any.
//
// Returns < 0 on error.
char* g_ipadress = NULL;
extern IDirectPlay8Server* g_pDPServer;
extern IDirectPlay8Client* g_pDPClient;
extern bool g_bVoiceCom;
extern char g_strVoiceHostIP[0x40];
extern bool stoppingvoice;
extern bool g_bACPlayerCTDFix;

int InitCommsStuff(ComDataClass *comData) {
	g_ipadress = ComAPIinet_htoa(comData->ip_address);//me123

	// we need to create both handles on startup, so as to haev the ports available
	ComAPIHandle tmpHandle = NULL, tmpHandle2 = NULL;
	int bigPipeBandwidth = -1;
	int smallPipeBandwidth = 2000;
	FalconTCPListenHandle = NULL;
	FalconGlobalUDPHandle = NULL;
	FalconGlobalTCPHandle = NULL;
	//	FalconInitialUDPHandle = NULL;
	FalconServerTCPStatus = VU_CONN_INACTIVE;
	//	DanglingConnections = NULL;

	// Shutdown any current games/connections
	SendMessage(FalconDisplay.appWin,FM_SHUTDOWN_CAMPAIGN,0,0);
	if (gConnectionStatus){
		EndCommsStuff();
	}
	gConnectionStatus = F4COMMS_ERROR_UDP_NOT_AVAILABLE;
	FalconConnectionDescription = FCT_WAN;
	SetupMessageSizes (FCT_WAN);
	// start BW FSM and set our ports
	ComAPIBWStart();
	ComAPISetLocalPorts(comData->localPort, comData->localPort+1);
	vuLocalSessionEntity->SetAddress(VU_ADDRESS(0, ComAPIGetMyRecvPort(), ComAPIGetMyReliableRecvPort()));

	// group handles
	// UDP
	FalconGlobalUDPHandle = ComAPICreateGroup("CreateGroup WAN FalconGlobalUDPHandle\n", F4CommsMaxUDPMessageSize,0);
	if (!FalconGlobalUDPHandle){
		return F4CommsConnectionCallback(F4COMMS_ERROR_UDP_NOT_AVAILABLE);
	}
	// TCP
	FalconGlobalTCPHandle = ComAPICreateGroup("WAN RUDP GROUP", F4CommsMaxTCPMessageSize,0);
	if (!FalconGlobalTCPHandle){
		return F4CommsConnectionCallback(F4COMMS_ERROR_MULTICAST_NOT_AVAILABLE);
	}

	// server
	if (comData->ip_address == 0){
		// this dangling represents the first client to connect to server
		// well receive initial data through it
		bool ret = AddDanglingSession(
			VU_ID(CAPI_DANGLING_ID, VU_SESSION_ENTITY_ID),
			VU_ADDRESS(CAPI_DANGLING_IP, ComAPIGetMyRecvPort(), ComAPIGetMyReliableRecvPort())
		);
		if (!(ret)) {
			return F4CommsConnectionCallback(F4COMMS_ERROR_UDP_NOT_AVAILABLE);
		}
	}
	// client
	else {
		// this is a dangling session representing server, so we can send first message
		bool ret = AddDanglingSession(
				VU_ID(CAPI_DANGLING_ID, VU_SESSION_ENTITY_ID),
				VU_ADDRESS(comData->ip_address, comData->remotePort, comData->remotePort+1)
		);
		if (!(ret)) {
			return F4CommsConnectionCallback(F4COMMS_ERROR_UDP_NOT_AVAILABLE);
		}
	}

	// We have UDP & RUDP and PTOP
	FalconConnectionProtocol = FCP_UDP_AVAILABLE | FCP_RUDP_AVAILABLE;
	FalconConnectionType = FCT_PTOP_AVAILABLE;
	F4CommsConnectionCallback(F4COMMS_CONNECTED);

	ComAPISetTimeStampFunction(TimeStampFunction);
	return gConnectionStatus;
}

// This gets called after we've made a connection (or failed for sure)
int F4CommsConnectionCallback (int result){
	if (result == F4COMMS_CONNECTED){
		int vures;

		// Init vu's comms
		if (!FalconGlobalTCPHandle){
			vures = gMainThread->InitComms(
				FalconGlobalUDPHandle, F4CommsMaxTCPMessageSize, F4CommsIdealTCPPacketSize,
				FalconGlobalUDPHandle, F4CommsMaxTCPMessageSize, F4CommsIdealTCPPacketSize,
				F4_EVENT_QUEUE_SIZE
			);
		}
		else {
			vures = gMainThread->InitComms(
				FalconGlobalUDPHandle, F4CommsMaxUDPMessageSize, F4CommsIdealUDPPacketSize,
				FalconGlobalTCPHandle, F4CommsMaxTCPMessageSize, F4CommsIdealTCPPacketSize,
				F4_EVENT_QUEUE_SIZE
			);
		}

		if (vures == VU_ERROR){
			// KCK: Vu often doesn't clean up after itself in this case!
			CleanupComms();
			return F4COMMS_ERROR_UDP_NOT_AVAILABLE;
		}
		gConnectionStatus = F4COMMS_CONNECTED;
	}
	else {
		CleanupComms();
	}
	// KCK: Call UI Comms connect callback
	gCommsMgr->StartCommsDoneCB(result);
	return result;
}

int CleanupComms (void)
{
	gConnectionStatus = 0;

	if (FalconGlobalUDPHandle)
		ComAPIClose(FalconGlobalUDPHandle);
	if (FalconGlobalTCPHandle)
		ComAPIClose(FalconGlobalTCPHandle);
	if (FalconTCPListenHandle)
		ComAPIClose(FalconTCPListenHandle);
	//	if (FalconInitialUDPHandle)
	//		ComAPIClose(FalconInitialUDPHandle);

	// Kill off any dangling sessions
	CleanupDanglingList();

	//	FalconInitialUDPHandle = NULL;
	FalconTCPListenHandle = NULL;
	FalconGlobalUDPHandle = NULL;
	FalconGlobalTCPHandle = NULL;
	FalconServerTCPStatus = VU_CONN_INACTIVE;
	return (TRUE);
}

int EndCommsStuff (void)
{
	if (gMainThread){
		gMainThread->LeaveGame();
	}

	// KCK HACK: To avoid vu's problem with shutting down comms when remote sessions are active
	VuSessionsIterator	siter(vuGlobalGroup);
	FalconSessionEntity	*cs;
	for (cs = (FalconSessionEntity*) siter.GetFirst(); cs != NULL;){
		FalconSessionEntity	*oldCs = cs;
		cs = (FalconSessionEntity*) siter.GetNext();
		oldCs->JoinGame(NULL);
	}
	// END HACK

	if (gConnectionStatus == F4COMMS_CONNECTED){
		gMainThread->DeinitComms();
	}

	CleanupComms();

	return (TRUE);
}

void SetupMessageSizes (int protocol)
{
	// Ideal packet size comms will send over the wire
	if (g_bF4CommsMTU){
		F4CommsIdealPacketSize = F4CommsMTU;  // Unz and Booster MTU tweek
	}
	else {
		F4CommsIdealPacketSize = 500;
	}

	// Corrisponding content sizes
	F4CommsIdealTCPPacketSize = F4CommsIdealPacketSize - COMMS_TCP_OVERHEAD;
	F4CommsIdealUDPPacketSize = F4CommsIdealPacketSize - COMMS_UDP_OVERHEAD;
	// Corrisponding messages sizes
	F4CommsMaxTCPMessageSize = F4CommsIdealTCPPacketSize * F4COMMS_MAX_PACKETS;
	F4CommsMaxUDPMessageSize = F4CommsIdealUDPPacketSize;
	// Maximum sized message vu can accept
	F4VuMaxTCPMessageSize = F4CommsMaxTCPMessageSize - PACKET_HDR_SIZE - MAX_MSG_HDR_SIZE;
	F4VuMaxUDPMessageSize = F4CommsMaxUDPMessageSize - PACKET_HDR_SIZE - MAX_MSG_HDR_SIZE;
	// Maximum sized packet vu with pack messages into
	F4VuMaxTCPPackSize = F4CommsIdealTCPPacketSize - PACKET_HDR_SIZE - MAX_MSG_HDR_SIZE;
	F4VuMaxUDPPackSize = F4CommsIdealUDPPacketSize - PACKET_HDR_SIZE - MAX_MSG_HDR_SIZE;
	protocol;
}

// =====================================
// Dangling session stuff
// =====================================

void InitDanglingList (void)
{
//	VuEnterCriticalSection();
	VuSessionFilter		DanglingSessionFilter(FalconNullId);
	DanglingSessionsList = new FalconPrivateList(&DanglingSessionFilter);
//	VuExitCriticalSection();
}

void CleanupDanglingList (void)
{
//	VuEnterCriticalSection();
	if (DanglingSessionsList){
		delete DanglingSessionsList;
	}
	DanglingSessionsList = NULL;
//	VuExitCriticalSection();
}

//sfr: converts
// changed prototype, changing ip for address and adding VU_ID
//void AddDanglingSession (ComAPIHandle ch1, ComAPIHandle ch2, VU_SESSION_ID id, VU_ADDRESS address)
bool AddDanglingSession(VU_ID owner, VU_ADDRESS address){
	VuEnterCriticalSection();
	FalconSessionEntity	*tempSess = NULL;

	// first time in dangling session, why not use a default constructor
	if (!DanglingSessionsList){
		InitDanglingList();
	}

	// Check if it's already in our list
	{
		VuListIterator dsit(DanglingSessionsList);
		for (
			FalconSessionEntity	*session = (FalconSessionEntity*)dsit.GetFirst();
			session != NULL;
			session = (FalconSessionEntity*)dsit.GetNext()
		){
			VU_ADDRESS sAdd = session->GetAddress();
			if (
					//(session->OwnerId().creator_.value_ == CAPI_DANGLING_ID) ||
					(session->OwnerId().creator_.value_ == owner.creator_) &&
					(sAdd == address)
			){
				// found one
				VuExitCriticalSection();
				return true;
				//tempSess = session;
				//break;
			}
		}
	}

	// session is not in list, create a new one and insert in list
	tempSess = new FalconSessionEntity(CAPI_DANGLING_ID, "tmp");
	tempSess->SetOwnerId(owner);
	tempSess->SetAddress(address);
	// KCK: Hackish. Need to trick VU into this is already inserted into DB, otherwise
	// it won't insert it into our list.
	tempSess->SetVuStateAccess(VU_MEM_ACTIVE);

	// temp session handle
	ComAPIHandle udpHandle = ComUDPOpen(
		"Dangling UDP",
		F4CommsMaxUDPMessageSize,
		vuxWorldName,
		vuLocalSessionEntity->GetAddress().recvPort,
		address.recvPort,
		address.ip,
		owner.creator_.value_
	);
	if (udpHandle == NULL){
		delete tempSess;
		VuExitCriticalSection();
		return false;
	}

	// handlers for this session
	tempSess->SetCommsHandle(udpHandle, F4CommsMaxUDPMessageSize, F4CommsIdealUDPPacketSize);
	tempSess->SetCommsStatus(VU_CONN_ACTIVE);

	// add handlers to UDP group handler (so we can send and receive data from it)
	ComAPIAddToGroup(FalconGlobalUDPHandle, udpHandle);

	DanglingSessionsList->ForcedInsert(tempSess);
	VuExitCriticalSection();
	return true;
}

//removes a dangling to open a permanent one (newSess)
//returns 1 if data was exchanged ok
// 0 if we had no dangling sessions or the session was not there
int RemoveDanglingSession (VuSessionEntity *newSess)
{
	int retval = 0;
	char buffer[100];

	// no dangling sessions
	if (!DanglingSessionsList){
		return retval;
	}

	VuEnterCriticalSection();
	// iterate over dangling sessions
	VuListIterator		dsit(DanglingSessionsList);
	for (
		VuSessionEntity	*session = (VuSessionEntity*)dsit.GetFirst();
		session != NULL;
		session = (VuSessionEntity*)dsit.GetNext()
	){
		VU_ADDRESS newAdd = newSess->GetAddress();
		VU_ADDRESS oldAdd = session->GetAddress();
		if (
				(session->OwnerId().creator_.value_ == CAPI_DANGLING_ID) ||
				(newSess->OwnerId().creator_.value_ == session->OwnerId().creator_)
		   ){
			// new sessions have no handle and old one does. exchange them
			if ((newSess->GetCommsHandle() == NULL) && (session->GetCommsHandle() != NULL)){
				newSess->SetCommsHandle(
					session->GetCommsHandle(), F4CommsMaxUDPMessageSize, F4CommsIdealUDPPacketSize
				);
				sprintf(buffer, "%s UDP", ((FalconSessionEntity*)newSess)->GetPlayerCallsign());
				ComAPISetName(newSess->GetCommsHandle(), buffer);
				// inherit status from session
				newSess->SetCommsStatus(session->GetCommsStatus());
				session->SetCommsHandle(NULL);
			}
			if ((newSess->GetReliableCommsHandle()==NULL) && (session->GetReliableCommsHandle() != NULL)){
				newSess->SetReliableCommsHandle(
					session->GetReliableCommsHandle(), F4CommsMaxTCPMessageSize, F4CommsIdealTCPPacketSize
				);
				sprintf(buffer, "%s RUDP", ((FalconSessionEntity*)newSess)->GetPlayerCallsign());
				ComAPISetName(newSess->GetReliableCommsHandle(), buffer);
				// inherity status from session
				newSess->SetReliableCommsStatus(session->GetReliableCommsStatus());
				session->SetReliableCommsHandle(NULL);
			}
			// remove old dangling session
			DanglingSessionsList->Remove(session);
			// sfr: no need to delete this anymore, since its derefed from list
			//delete session;
			retval = 1;
			break;
		}
	}
	VuExitCriticalSection();
	return retval;
}

int UpdateDanglingSessions (void)
{
	if (gConnectionStatus)
	{
		VuEnterCriticalSection();
		VuListIterator		dsit(DanglingSessionsList);
		VuSessionEntity		*session;
		int					count = 0;

		for (session = (VuSessionEntity*)dsit.GetFirst(); session; session = (VuSessionEntity*)dsit.GetNext()){
			count += session->GetMessages();
			// attempt to send one packet of each type
			session->FlushOutboundMessageBuffer();
		}

		VuExitCriticalSection();
		return count;
	}
	return 0;
}

// =====================================
// COMMS callbacks (registering handles)
// =====================================

// Callback from comms to register a tcp handle
// This gets called when someone sent a message to our TCP listen socket
#if 0
void TcpAcceptCallback(ComAPIHandle ch)
{
	ulong				ipaddr;
	VuSessionEntity*	s;
	VuSessionsIterator	siter(vuGlobalGroup);

	// need to find session...
	ipaddr = ComAPIQuery(ch, COMAPI_CONNECTION_ADDRESS);

	// map ipaddr to session
	for (s = siter.GetFirst(); s; s = siter.GetNext())
	{
		if (s->Id().creator_.value_ == ipaddr)
		{
			MonoPrint("TcpAcceptCallback connection -- made to 0x%x ch = %p\n", ipaddr, ch);
			s->SetReliableCommsHandle(ch, F4CommsMaxTCPMessageSize, F4CommsIdealTCPPacketSize);
			s->SetReliableCommsStatus(VU_CONN_ACTIVE);
			// Request global entities from this guy
			VuMessage *req = new VuGetRequest(VU_GET_GLOBAL_ENTS,s);
			req->RequestReliableTransmit();
			VuMessageQueue::PostVuMessage(req);
			return;
		}
	}
	MonoPrint("TcpAcceptCallback error -- couldn't find session 0x%x\n", ipaddr);
	// should we disconnect here?
}

// This gets called as a result of us calling ComTCPOpenConnect (attempting to connect TCP)
// ret == 0 means success
void TcpConnectCallback(ComAPIHandle ch, int ret)
{
	ulong				ipaddr;

	ipaddr = ComAPIQuery(ch, COMAPI_CONNECTION_ADDRESS);

	MonoPrint("Calling TcpConnectCallback.\n");

	if (ret != 0)
	{
		MonoPrint ("RequestConnection failed %d, will retry\n", ret);
		return;
	}

	// Check if we're connecting to a server first...
	if (FalconConnectionType == FCT_SERVER_AVAILABLE)
	{
		FalconGlobalTCPHandle = ch;
		if (ch)
		{
			FalconServerTCPStatus = VU_CONN_ACTIVE;
			if (gConnectionStatus == F4COMMS_PENDING)
				F4CommsConnectionCallback(F4COMMS_CONNECTED);
		}
		else
		{
			FalconServerTCPStatus = VU_CONN_INACTIVE;	// This would be bad..
			F4CommsConnectionCallback(F4COMMS_ERROR_COULDNT_CONNECT_TO_SERVER);
		}
		return;
	}

	// Otherwise, look for the correct session
	VuEnterCriticalSection();
	VuSessionEntity*	s;
	VuSessionsIterator	siter(vuGlobalGroup);
	for (s = siter.GetFirst(); s; s = siter.GetNext())
	{
		if (s->Id().creator_.value_ == ipaddr)
		{
			RemoveDanglingSession(s);
			if (ch && s->GetCommsHandle() == ch)
				s->SetCommsStatus(VU_CONN_ACTIVE);
			if (ch && s->GetReliableCommsHandle() == ch)
				s->SetReliableCommsStatus(VU_CONN_ACTIVE);
			VuExitCriticalSection();
			if (gConnectionStatus == F4COMMS_PENDING)
				F4CommsConnectionCallback(F4COMMS_CONNECTED);
			// Request global entities from this guy
			VuMessage *req = new VuGetRequest(VU_GET_GLOBAL_ENTS,s);
			req->RequestReliableTransmit();
			VuMessageQueue::PostVuMessage(req);
			return;
		}
	}

	// We're connected (although we're not yet ready to send)
	if (gConnectionStatus == F4COMMS_PENDING){
		F4CommsConnectionCallback(F4COMMS_CONNECTED);
	}

	// Add this connection to our "dangling connection" list
	AddDanglingSession(NULL, ch, ipaddr, ipaddr);
	VuExitCriticalSection();
}

// This gets called as a result of us calling ComDPLAYOpen and getting a modem connection
// ret == 0 means success
void ModemConnectCallback(ComAPIHandle ch, int ret)
{
	ulong				ipaddr;

	ipaddr = ComAPIQuery(ch, COMAPI_CONNECTION_ADDRESS);

	ShiAssert ( ch == FalconGlobalUDPHandle );		// We should only have one connection!

	// need to find session... There should be only two (us and them)
	VuEnterCriticalSection();
	VuSessionEntity*	s;
	VuSessionsIterator	siter(vuGlobalGroup);
	for (s = siter.GetFirst(); s; s = siter.GetNext())
	{
		if (s != FalconLocalSession)
		{
			if (ret == 0)
			{
				MonoPrint("ModemConnectCallback invoked: connected!\n");
				s->SetReliableCommsHandle(ch, F4CommsMaxTCPMessageSize, F4CommsIdealTCPPacketSize);
				s->SetReliableCommsStatus(VU_CONN_ACTIVE);
				// Request global entities from this guy
				VuMessage *req = new VuGetRequest(VU_GET_GLOBAL_ENTS,s);
				req->RequestReliableTransmit();
				VuMessageQueue::PostVuMessage(req);
				if (gConnectionStatus == F4COMMS_PENDING)
					F4CommsConnectionCallback(F4COMMS_CONNECTED);
			}
			else
			{
				MonoPrint("ModemConnectCallback invoked: bad connection.\n");
				s->SetReliableCommsHandle(NULL);
				s->SetReliableCommsStatus(VU_CONN_INACTIVE);
			}
			VuExitCriticalSection();
			return;
		}
	}
	if (gConnectionStatus == F4COMMS_PENDING)
		F4CommsConnectionCallback(F4COMMS_CONNECTED);
	// Add this connection to our "dangling connection" list
	AddDanglingSession(NULL, ch,  ipaddr, ipaddr);
	MonoPrint("ModemConnectCallback invoked: saving handle..\n");
	VuExitCriticalSection();
}
#endif

// ====================================
// Time synchonizing stuff
// ====================================

// This routine will determine the proper time compression to run at after polling
// all sessions in the game.
//why are we taking force as a parameter when we aren't using it?
void ResyncTimes(){
	int count, 	best_comp;
	VuGroupEntity *g = FalconLocalGame;
	VuEnterCriticalSection ();
	VuSessionsIterator	sit(g);
	FalconSessionEntity *session;

	best_comp = 1;

	if (gTimeModeServer||g_bServer){
		session = (FalconSessionEntity*)sit.GetFirst();
		count = 0;

		while (session){
			if (!session->IsLocal ()){
				count ++;
				best_comp = session->GetReqCompression();
				break;
			}
			session = (FalconSessionEntity*)sit.GetNext();
		}

		if (count == 0){
			best_comp = FalconLocalSession->GetReqCompression();
		}
	}
	else {
		best_comp = FalconLocalSession->GetReqCompression();
	}

	// KCK: Currently, everyone polls locally, but only sets time compression upon
	// notice from the host. We may prefer to send the host's poll data with the timing
	// message.
	remoteCompressionRequests = 0;

	session = (FalconSessionEntity*)sit.GetFirst();
	while (session){
		if (gTimeModeServer||g_bServer){
			if (session->IsLocal ()){
				session = (FalconSessionEntity *) sit.GetNext ();
				continue;
			}
		}

		if (session->GetReqCompression() > 1 && session->GetReqCompression() < best_comp){
			best_comp = session->GetReqCompression();
			remoteCompressionRequests |= 1 << (best_comp-1);
		}

		if (session->GetReqCompression() < 1 && session->GetReqCompression() > best_comp){
			best_comp = session->GetReqCompression();
			remoteCompressionRequests |= REMOTE_REQUEST_PAUSE;
		}

		if (session->GetReqCompression() == 1){
			best_comp = session->GetReqCompression();
		}

		if (session->GetReqCompression() == 0 && best_comp > 1){
			best_comp = 1;
		}

		session = (FalconSessionEntity*)sit.GetNext();
	}
	VuExitCriticalSection ();

	if (FalconLocalGame && FalconLocalGame->IsLocal()){
		lastStartTime = vuxRealTime;

		// Let the Campaign adjust itself to the target compression ratio
		targetCompressionRatio = best_comp;

		//MonoPrint ("Sending Timing Message %08x %d\n", vuxGameTime, targetCompressionRatio);
		FalconTimingMessage	*msg = new FalconTimingMessage(FalconNullId,FalconLocalGame);
		msg->RequestOutOfBandTransmit();
		FalconSendMessage(msg,TRUE);
	}
}

// Time stamp function used by Comms and Vu to try and reduce latency in time stamping
ulong TimeStampFunction(){
	return vuxRealTime;
}

//////////////////////////////////
// VUX STUFF
//////////////////////////////////

bool VuxAddDanglingSession (VU_ID owner, VU_ADDRESS address){
	return AddDanglingSession(owner, address);
}

// ==========================
// COMMS handle creation
// ==========================
// Set up a handle to communicate via UDP with everyone in this group.
int VuxGroupConnect(VuGroupEntity *group)
{
	char
		buffer[100],
		*name;

	if (group->IsGame())
	{
		name = ((VuGameEntity*)group)->GameName();
		MonoPrint("Connecting to game: %s\n",((VuGameEntity*)group)->GameName());
	}
	else
	{
		name = group->GroupName();
		MonoPrint("Connecting to group: %s\n",group->GroupName());
	}

	// Check for existing connections
	if (!group->GetCommsHandle())
	{
		if (!(FalconConnectionProtocol & FCP_UDP_AVAILABLE) && !(FalconConnectionProtocol & FCP_SERIAL_AVAILABLE))
		{
			// No udp connections available
			group->SetCommsHandle(NULL);
			group->SetCommsStatus(VU_CONN_INACTIVE);
		}
		else if (FalconConnectionType & FCT_SERIAL_AVAILABLE)
		{
			group->SetCommsHandle(NULL);		// We'll inherit from our global group
			group->SetCommsStatus(VU_CONN_ACTIVE);
		}
		else if (FalconConnectionType & FCT_SERVER_AVAILABLE && FalconGlobalUDPHandle)
		{
			// Point us to our server's UDP connection
			group->SetCommsHandle(NULL);		// We'll inherit from our global group
			group->SetCommsStatus(VU_CONN_ACTIVE);
		}
		else if (FalconConnectionType & FCT_BCAST_AVAILABLE && FalconGlobalUDPHandle)
		{
			// Since we have broadcast available, pass our broadcast handle
			group->SetCommsHandle(NULL);		// We'll inherit from our global group
			group->SetCommsStatus(VU_CONN_ACTIVE);
		}
		else if (FalconConnectionType & FCT_PTOP_AVAILABLE)
		{
			// Point to Point only - Create a new comms group which we will add shit to.
			sprintf (buffer, "%s UDP", name);
			MonoPrint ("CreateGroup %s\n", buffer);
			ComAPIHandle	gh = ComAPICreateGroup(buffer, F4CommsMaxUDPMessageSize,0);
			group->SetCommsHandle(gh, F4CommsMaxUDPMessageSize, F4CommsIdealUDPPacketSize);
			if (gh)
				group->SetCommsStatus(VU_CONN_ACTIVE);
			else
				group->SetCommsStatus(VU_CONN_INACTIVE);
		}
		else
		{
			// No communication available.
			group->SetCommsHandle(NULL);
			group->SetCommsStatus(VU_CONN_INACTIVE);
		}
	}
	if (!group->GetReliableCommsHandle())
	{
		if (!(FalconConnectionProtocol & FCP_TCP_AVAILABLE) && !(FalconConnectionProtocol & FCP_SERIAL_AVAILABLE) && !(FalconConnectionProtocol & FCP_RUDP_AVAILABLE))
		{
			// No reliable connections available
			group->SetReliableCommsHandle(NULL);
			group->SetReliableCommsStatus(VU_CONN_INACTIVE);
		}
		else if (FalconConnectionType & FCT_SERIAL_AVAILABLE)
		{
			group->SetCommsHandle(NULL);		// We'll inherit from our global group
			group->SetCommsStatus(VU_CONN_ACTIVE);
		}
		else if (FalconConnectionType & FCT_SERVER_AVAILABLE && FalconGlobalTCPHandle)
		{
			// Point us to our server's tcp connection
			group->SetCommsHandle(NULL);		// We'll inherit from our global group
			group->SetReliableCommsStatus(VU_CONN_ACTIVE);
		}
		else if (FalconConnectionType & FCT_PTOP_AVAILABLE)
		{
			// Point to Point only - Create a new comms group which we will add shit to.
			sprintf (buffer, "%s RUDP", name);
			MonoPrint ("CreateGroup %s\n", buffer);
			ComAPIHandle	gh = ComAPICreateGroup(buffer, F4CommsMaxTCPMessageSize,0);
			group->SetReliableCommsHandle(gh, F4CommsMaxTCPMessageSize, F4CommsIdealTCPPacketSize);
			if (gh)
				group->SetReliableCommsStatus(VU_CONN_ACTIVE);
			else
				group->SetReliableCommsStatus(VU_CONN_INACTIVE);
		}
		else
		{
			// No reliable group communication available.
			group->SetReliableCommsHandle(NULL);
			group->SetReliableCommsStatus(VU_CONN_INACTIVE);
		}
	}
	if(gUICommsQ && group->IsGame())
		gUICommsQ->Add(_Q_GAME_ADD_,FalconNullId,group->Id());

	return 0;
}

void VuxGroupDisconnect(VuGroupEntity *group)
{
	ComAPIHandle ch;

	if (group->IsGame())
	{
		MonoPrint("Disconnecting to game: %s\n",((VuGameEntity*)group)->GameName());
	}
	else
	{
		MonoPrint("Disconnecting to group: %s\n",group->GroupName());
	}

	// Disconnect UDP
	ch = group->GetCommsHandle();
	group->SetCommsHandle(NULL);
	group->SetCommsStatus(VU_CONN_INACTIVE);
	if (ch && ch != FalconGlobalUDPHandle)
		ComAPIClose(ch);
	// Disconnect TCP
	ch = group->GetReliableCommsHandle();
	group->SetReliableCommsHandle(NULL);
	group->SetReliableCommsStatus(VU_CONN_INACTIVE);
	if (ch && ch != FalconGlobalTCPHandle)
		ComAPIClose(ch);

	if(gUICommsQ && group->IsGame())
		gUICommsQ->Add(_Q_GAME_REMOVE_,FalconNullId,group->Id());
}

int VuxGroupAddSession(VuGroupEntity *group, VuSessionEntity *session)
{
	ComAPIHandle	gh,sh;
	if (g_bVoiceCom)
	{
		if (strcmpi(g_strVoiceHostIP, "")){
			g_ipadress = g_strVoiceHostIP;
		}
		if (
			(gConnectionStatus == F4COMMS_CONNECTED ||
			(g_ipadress && !strcmpi(g_ipadress, "0.0.0.0"))) &&
			!stoppingvoice && !g_pDPServer && !g_pDPClient  && (g_ipadress)
		){
			startupvoice(g_ipadress);//me123
		}
	}

	// sfr bw control
	// adjusted only for games
	if (group->IsGame()){
		FalconGameEntity *game = static_cast<FalconGameEntity*>(group);
		if (session == vuLocalSessionEntity){
			// adding ourselves to group
			if (game == vuPlayerPoolGroup){
				ComAPIBWEnterState(CAPI_LOBBY_ST);
			}
			else {
				switch (game->gameType){
					//case game_PlayerPool:
					//	ComAPIBWEnterState(CAPI_LOBBY_ST);
					//break;
					case game_Dogfight:
						ComAPIBWEnterState(CAPI_DF_ST);
					break;
					case game_TacticalEngagement:
					case game_Campaign:
						// here is different if we are host, for others its the same
						ComAPIBWEnterState((game->OwnerId() == vuLocalSession) ? CAPI_CAS_ST : CAPI_CAC_ST);
					break;
					default:
						; // do nothing
				}
			}
			// if game is not ours, we need to update bw to reflect other players already in
			if (game->OwnerId() != vuLocalSessionEntity->Id()){
				for (unsigned int players = game->SessionCount();players>0;--players){
					ComAPIBWPlayerJoined();
				}
			}
		}
		else if (game == vuLocalGame) {
			// adding others to group
			ComAPIBWPlayerJoined();
		}
	}

	gh = group->GetCommsHandle();
	sh = session->GetCommsHandle();
	if (gh && sh && gh != sh){
		ComAPIAddToGroup(gh,sh);
	}
	gh = group->GetReliableCommsHandle();
	sh = session->GetReliableCommsHandle();
	if (gh && sh && gh != sh){
		ComAPIAddToGroup(gh,sh);
	}

	// UI Related
	if(gUICommsQ && group->IsGame()){
		gUICommsQ->Add(_Q_SESSION_ADD_,session->Id(),group->Id());
	}

	// Send FullUpdate for session if this is our game
	if (
		(group->IsGame ()) &&
		(group->Id() == vuLocalSessionEntity->GameId()) &&
		(vuLocalSessionEntity.get() != session)
	){
		VuFullUpdateEvent *msg = new VuFullUpdateEvent (vuLocalSessionEntity.get(), session);
		msg->RequestReliableTransmit ();
		VuMessageQueue::PostVuMessage(msg);
	}

	return 1;
}

int VuxGroupRemoveSession(VuGroupEntity *group, VuSessionEntity *session)
{
	// check if session is in group
	if (!group->SessionInGroup(session)){
		return VU_NO_OP;
	}

	ComAPIHandle gh,sh;

	if (group->IsGame()){
		FalconGameEntity *game = static_cast<FalconGameEntity*>(group);
		if (session == vuLocalSessionEntity){
			// were leaving game
			ComAPIBWEnterState(CAPI_LOBBY_ST);
		}
		else if (group == vuLocalGame){
			// player left game were in
			ComAPIBWPlayerLeft();
		}
	}

	gh = group->GetCommsHandle();
	sh = session->GetCommsHandle();
	if (gh && sh && (gh != sh)){
		ComAPIDeleteFromGroup(gh,sh);
	}
	//	if (sh == FalconInitialUDPHandle && gh == FalconGlobalUDPHandle)
	//		FalconInitialUDPHandle = NULL;
	gh = group->GetReliableCommsHandle();
	sh = session->GetReliableCommsHandle();
	if (gh && sh && gh != sh){
		ComAPIDeleteFromGroup(gh,sh);
	}

	if(gUICommsQ){
		gUICommsQ->Add(_Q_SESSION_REMOVE_,session->Id(),group->Id());
	}

	// VWF 12/1/98: Added this to clean up player's flight when he leaves game
	if ((FalconLocalGame == group) && (FalconLocalGame->IsLocal()))
	{
		Flight flight = ((FalconSessionEntity*)session)->GetAssignedPlayerFlight();
		if(flight){
			LeaveACSlot(
				((FalconSessionEntity*)session)->GetAssignedPlayerFlight(),
				((FalconSessionEntity*)session)->GetAssignedAircraftNum()
			);
			// Make sure this session doesn't have any old information
		}
	}
	// END VWF

	((FalconSessionEntity*)session)->SetPlayerSquadron (NULL);
	((FalconSessionEntity*)session)->SetPlayerFlight (NULL);
	((FalconSessionEntity*)session)->SetPlayerEntity (NULL);
	((FalconSessionEntity*)session)->SetAircraftNum (255);
	((FalconSessionEntity*)session)->SetPilotSlot (255);
	((FalconSessionEntity*)session)->SetAssignedAircraftNum (255);
	((FalconSessionEntity*)session)->SetAssignedPilotSlot (255);
	((FalconSessionEntity*)session)->SetAssignedPlayerFlight (NULL);

	return 1;
}

// Set up a handle to communicate this session.
int VuxSessionConnect(VuSessionEntity *session)
{
	//	char buffer[100];
	int wait_for_connection = 0;

	// We only want to connect here during our initial insertion
	if (session->GameAction() != VU_NO_GAME_ACTION){
		return 0;
	}

	if (session == vuLocalSessionEntity)
	{
		// This is us.. We don't need to connect
		session->SetCommsHandle(NULL);
		session->SetCommsStatus(VU_CONN_INACTIVE);
		session->SetReliableCommsHandle(NULL);
		session->SetReliableCommsStatus(VU_CONN_INACTIVE);
		return 0;
	}
	// add dangling session now if it doesnt exist
	AddDanglingSession(session->Id(), session->GetAddress());
	RemoveDanglingSession(session);
	// now create the reliable handle if we dont have one
	if (session->GetReliableCommsHandle() == NULL){
		char buffer[20];
		sprintf (buffer, "%s RUDP", ((FalconSessionEntity*)session)->GetPlayerCallsign());
		//sfr: vu change converts
		VU_ADDRESS add = session->GetAddress();
		ComAPIHandle rudpHandle = ComRUDPOpen(
				buffer,
				F4CommsMaxTCPMessageSize,
				vuxWorldName,
				vuLocalSessionEntity->GetAddress().reliableRecvPort,
				add.reliableRecvPort,
				add.ip,
				session->Id().creator_.value_,
				F4CommsIdealPacketSize
		);
		session->SetReliableCommsHandle(rudpHandle, F4CommsMaxTCPMessageSize, F4CommsIdealTCPPacketSize);
		if (rudpHandle){
			session->SetReliableCommsStatus(VU_CONN_ACTIVE);
		}
		else{
			session->SetReliableCommsStatus(VU_CONN_INACTIVE);
		}
	}
	// Add to the global group
	VuxGroupAddSession(vuGlobalGroup, session);

	//sfr: this can be a duplicated message (see function VuxGroupAddSession)
	{
		//send ourselves to session we are opening connection
		VuMessage *req = new VuFullUpdateEvent(vuLocalSessionEntity.get(), session);
		req->RequestOutOfBandTransmit();
		//req->Send();
		VuMessageQueue::PostVuMessage(req);
	}
	{
		// and request all global ents
		VuMessage *req = new VuGetRequest(VU_GET_GLOBAL_ENTS,session);
		//req->RequestReliableTransmit();
		req->RequestOutOfBandTransmit();
		//req->Send();
		VuMessageQueue::PostVuMessage(req);
	}

	return 0;
}

void VuxSessionDisconnect(VuSessionEntity *session)
{

	if (session == FalconLocalSession)
		return;

	// We only want to do this if we're leaving a game (i.e: This session is going away)
	if (session->GameAction() != VU_LEAVE_GAME_ACTION)
		return;

	Flight playerFlight = (Flight)((FalconSessionEntity*)session)->GetAssignedPlayerFlight();
	int acnumber = ((FalconSessionEntity*)session)->GetAssignedAircraftNum();

	if (g_bACPlayerCTDFix && playerFlight && FalconLocalGame->IsLocal()) // only the host...
	{
		FalconPlayerStatusMessage	*msg = new FalconPlayerStatusMessage(((FalconSessionEntity*)session)->Id(), FalconLocalGame);
		SimBaseClass				*playerEntity = (SimBaseClass*) ((FalconSessionEntity*)session)->GetPlayerEntity();

		// first change the deag owner of our disconnected player back to the host
		/*	if (playerEntity)
			{
			FalconSimCampMessage	*simmsg = new FalconSimCampMessage (playerEntity->Id(), FalconLocalGame); // target);
			simmsg->dataBlock.from = FalconLocalGame->OwnerId();
			simmsg->dataBlock.message = FalconSimCampMessage::simcampChangeOwner;
			FalconSendMessage(simmsg);
			}
			*/
		if (((FalconSessionEntity*)session)->GetPlayerFlight())
		{
			msg->dataBlock.campID		= ((FalconSessionEntity*)session)->GetPlayerFlight()->GetCampID();
		}
		else
		{
			msg->dataBlock.campID		= 0;
		}

		if (playerEntity)
		{
			msg->dataBlock.playerID         = playerEntity->Id();
		}

		_tcscpy(msg->dataBlock.callsign,((FalconSessionEntity*)session)->GetPlayerCallsign());

		msg->dataBlock.side             = ((FalconSessionEntity*)session)->GetCountry();
		msg->dataBlock.pilotID          = ((FalconSessionEntity*)session)->GetPilotSlot();
		msg->dataBlock.vehicleID		= ((FalconSessionEntity*)session)->GetAircraftNum();
		msg->dataBlock.state            = PSM_STATE_LEFT_SIM;

		FalconSendMessage(msg, TRUE);
		((FalconSessionEntity*)session)->SetFlyState(FLYSTATE_IN_UI);

		// and now we need to do some hacking... the current code doesn't really support to change ownership
		// of single aircraft

		// Get the Aircraftclass entity
		AircraftClass *playerAircraft = NULL;

		if (playerFlight)
			playerAircraft = (AircraftClass *)playerFlight->GetComponentEntity(acnumber);

		// when we still have one, just make local to the host
		if (playerAircraft)
		{
			playerAircraft->MakeLocal();
		}
	}

	// 2002-04-14 MN remove the disconnected (CTD'ed, Internet connection lost) player from its slot so it can be occupied again
	LeaveACSlot (((FalconSessionEntity*)session)->GetAssignedPlayerFlight(), ((FalconSessionEntity*)session)->GetAssignedAircraftNum());

	// Remove from the global group
	VuxGroupRemoveSession(vuGlobalGroup,session);

	if (session->GetCommsStatus() != VU_CONN_INACTIVE || session->GetReliableCommsStatus() != VU_CONN_INACTIVE)
	{
		MonoPrint("Disconnecting to session: %s\n",((FalconSessionEntity*)session)->GetPlayerCallsign());
	}

	/* me123 commented this out
	   it prevents us from removing the session from other lists then the global group.
	   it should not matter since the session will be removed totaly right after this.
	// Disconnect UDP
	ch = session->GetCommsHandle();
	session->SetCommsHandle(NULL);
	session->SetCommsStatus(VU_CONN_INACTIVE);
	if (session && ch && ch != FalconGlobalUDPHandle)
	ComAPIClose(ch);
	// Disconnect TCP
	ch = session->GetReliableCommsHandle();
	session->SetReliableCommsHandle(NULL);
	session->SetReliableCommsStatus(VU_CONN_INACTIVE);
	if (session && ch && ch != FalconGlobalTCPHandle)
	ComAPIClose(ch);
	*/
}

void VuxAdjustLatency(VU_TIME, VU_TIME)
{
	// KCK NOTE: This is stubbed 'cause we're not using VU's latency checking
	//	SynchronizeTime(vuLocalSessionEntity->Group());
	//	MonoPrint("Called VuxAdjustLatency(%d, %d)\n", t1, t2);
}

redpajama_set_name: RedPajamaGithub


SAN JUAN—The Supreme Court ruled on Thursday that Puerto Rico remains a U.S. territory without the independent powers of a sovereign state when it comes to enforcement of criminal law.
The justices' 6-2 ruling on the Puerto Rico v. Sánchez Valle case says Congress is the ultimate source of the island's legal power even though Puerto Rico has its own constitution.
Justice Elena Kagan, a Democratic Party nominee, delivered the majority opinion while Justices Sonia Sotomayor and Stephen Breyer wrote dissenting opinions. Justices Clarence Thomas and Ruth Bader Gingsburg wrote concurring opinions.
Breyer, in his opinion, wrote that he does not believe that Puerto Rico and the federal government share the same source of power—namely, the U. S. Congress—because the historical context shows that the United States intended to change the nature of its relationship with Puerto Rico by granting it self-government.
"I do not believe, as the majority seems to believe, that the double jeopardy question can be answered simply by tracing Puerto Rico's current legislative powers back to Congress' enactment of Public Law 600 and calling the Congress that enacted that law the "source" of the island's criminal-enforcement authority," Breyer's opinion stated.
"That is because—as with the Philippines, new States, and the Indian tribes—congressional activity and other historic circumstances can combine to establish a new source of power. We therefore must consider Public Law 600 in the broader context of Puerto Rico's history. Only through that lens can we decide whether the Commonwealth, between the years 1950 and 1952, gained sufficient sovereign authority to become the "source" of power behind its own criminal laws," he said.
Breyer added that in enacting Law 600, the Puerto Rican Federal Relations Act determined that the "political status" of Puerto Rico would for double jeopardy purposes subsequently encompass the sovereign authority to enact and enforce— pursuant to its own powers—its own criminal laws. Several considerations support this conclusion.
He also noted that the timing of Public Law 600's enactment suggests that Congress intended it to work a significant change in the nature of Puerto Rico's political status. Prior to 1950, Puerto Rico was initially subject to the Foraker Act, which provided the Federal Government with virtually complete control of the island's affairs.
In 1917, Puerto Rico became subject to the Jones Act, which provided for United States citizenship and permitted Puerto Ricans to elect local legislators but required submission of local laws to Congress for approval. In 1945, the United States, when signing the United Nations Charter, promised change. It told the world that it would "develop self-government" in its territories.
Breyer noted that President Truman himself noted that change in the political nature of the relationship with the island when he said that the power in the constitution emanated from the people, a view held by subsequent administrations and local Supreme Court.
He added that in analyzing the nature of the relationship, one has to examine the actions of the United States. "I would add that the practices, actions, statements, and attitudes just described are highly relevant here, for this Court has long made clear that, when we face difficult questions of the Constitution's structural requirements, longstanding customs and practices can make a difference," he said.